logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: perltray/tk intercept windows minimize function: msg#00019

Subject: Re: perltray/tk intercept windows minimize function
I have to admit that I haven't been following this thread as closely as I should, but I do agree that breaking or putting a new and unexpected behavior on the minimize button is *not* a Good Thing. That's why I think it's better to remove it if you don't want the default behavior.

I'd also like to add that Nick added a nice tidbit that I wasn't aware of, and it's to your advantage to use it. I believe it adds value to the solution I posted. The modified code might look like this:

use Tk;
use Win32::GUI;

my $mw = MainWindow->new;

my $winH = hex($mw->frame);
my $style = Win32::GUI::GetWindowLong($winH, -16);
$style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
Win32::GUI::SetWindowLong($winH, -16, $style);
Win32::GUI::DrawMenuBar($winH);

MainLoop;

With this addition, you may only save one line of code which you may end up using anyway (to give the MainWindow a title), but it's less error prone and cleaner IMO to directly use the HWND if it's available rather than search for it as I did. This is what Nick was saying in his response to my response. It's what I would have used originally if I'd known about it.

Unfortunately, I do not have Win32Util installed on my Win32 version of Perl so I can't help you with your other problem, have you attempted to call maximize *before* removing the minimize button rather than after?

Rob

listmail wrote:
Thanks for the response. I found a similar response to yours addressed to me from someone on the ptk list while viewing the codecomments archives. Looks like I haven't been getting the ptk emails for who knows how long. Hopefully I can get that fixed soon. I liked Rob's solution by removing the buttons, this seemed cleaner and easier to support after implementing it.



Nick Ing-Simmons wrote:
Listmail <listmail@xxxxxxxxxxxx> writes:
I'm not sure what that last bit is all about :), but the user uses the application like a vast majority of other applications coded to run in the system tray by interacting with the system tray icon as opposed to a task bar button. Typically, double clicking the system tray icon redraws the application right where it left off or right clicking the system tray icon can provide the user with a menu with that contains that same "redraw" option as well a few others like "hide" and "exit" (as shown below). Most "system tray" applications that I know of create a "minimize to the system tray" effect instead of remaining a task bar button.

Okay, I can see why you want to do what you suggest then.
And you DO want to minimize the application so you are not breaking the user's mental model of what s/he is asking machine to do. Fine.

But as you are minimizing ... widget is not going to be destroyed but just hidden.

First an aside:
[On X what happens is that when user clicks on minimize button window manager withdraws the main window and that sends an event to the application.
Window manager may then display an icon on the desktop or in a tray.
Application can however withdraw the _icon_ (which is just another window). So on X you don't override minimize but instead bind to the visibility event(s) on the application window and the icon window
]

Meanwhile back in wonderful world of Windows there is no doubt a whole other mechanism which presumably allows same effects.

How Windows part of core-tk maps windows events to X-like ones is sometimes a little strange but it does try.
(Tcl/Tk started on X and still retains an X-like view of the world.)
So it is possible that you can get what you want by
a bind :

  $toplevel->bind('<Unmap>',YourCallback);

<Unmap> may not be the right event, but is what X would do.

See if that gives you the hook to cache the minimize. Then I think if you withdraw the window the task-bar icon will go too.

If that doesn't work then you probably need a new "window class" registered which is easy to do in a C/C++ application but I have never set anything up
to do it from perl.





-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx


-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx




-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx




Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>