Re: perltrak/tk intercept windows minimize function
Rob Seegel <[email protected]>
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
I posted this to the Newsgroup back in December, maybe it will be useful
again. Note that it is specific to Windows, and it doesn't intercept the
minimize action, but it does show how you might hide the button.
Rob
cengizhana...
<http://groups.google.com/groups/unlock?msg=8036287d9a3d5d6c&_done=/group/comp.lang.perl.tk/msg/8036287d9a3d5d6c>@googlemail.com
wrote:
> Hi,
> Does anybody know how only the maximize/restore button can be
> deactivated? If i use the following code, minimize button is also
> disappears and only the exit button stays on the right corner.
> my $mw=tkinit;
> $mw->geometry("0x0");
> $mw->overrideredirect(1);
> my $main = $mw->Toplevel;
> $main->transient($mw);
> $main->protocol('WM_DELETE_WINDOW' => sub {exit(0)});
Whatever solution you find is likely to be platform specific and tied to
a specific Window Manager. By way of example, I recently found a way to
remove individual decorations from a Win32 window. Note that it involves
intervention of Win32::GUI. As a side note, this example led me to
discover that the HWND returned by MainWindow, was not the same HWND
returned by Win32::GUI::FindWindow. This came as a mild surprise, since
I've generally had good luck with the HWND's returned by other GUI widgets.
use Tk;
use Win32::GUI;
my $mw = MainWindow->new;
$mw->title("Hello");
$mw->update;
my ($winH) = Win32::GUI::FindWindow("", "Hello");
my $style = Win32::GUI::GetWindowLong($winH, -16);
$style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
Win32::GUI::SetWindowLong($winH, -16, $style);
Win32::GUI::DrawMenuBar($winH);
MainLoop;
Rob
Nick Ing-Simmons wrote:
> Listmail <[email protected]> writes:
>
>> Is there anyway to intercept when the user clicks the Minimize button on
>> a tk window and call
>> $mw->withdraw instead? I understand that the Minimize function is part
>> of the Windows OS
>> window manager subsystem.
>>
>
>
> I believe if you mark the window as 'transient' - like a popup
> then you don't get a minimize button. Is that any help?
>
>
>> google shows similar questions have been asked, but I haven't been able
>> to determine what I need to do when using perltray.
>>
>
> What is "perltray" ?
>
>
>> Sorry if I'm beating a dead horse,
>> but I think this would
>> be something a few people would like to achieve.
>>
>
> Overriding standard GUI behaviour should not be done lightly.
> If the platfrom has a minimize button it should minimize.
>
> It should NOT withdraw - how does the poor user get it back once
> (say) he has Copy-ed something from a window and wants to Paste it in?
>
> Or if Copy/Paste isn't possible suppose it is minimized so they can do other
> work until than can get it back and ask someone about it.
>
> "Doctor the machine said something about the patient's heart,
> I have the message here somewhere..."
>
>
>
>> Note: I was able to call withdraw while clicking the Windows Close
>> button (X)
>> by using the following:
>> $mw->protocol('WM_DELETE_WINDOW', sub{ $mw->withdraw; })
>> This effectively creates a "~close~ to the system tray" feel when using
>> perltray compiled code.
>>
>> PDK 6.0.2
>> ActivePerl 5.8.7 build 813
>>
>> #base code example (many thanks to Jan)
>> #!perl
>> use strict;
>> use warnings;
>> use Tk;
>> use PerlTray;
>>
>> our $mw = MainWindow->new(-title => 'test');
>>
>> $mw->protocol('WM_DELETE_WINDOW', sub{ $mw->withdraw; });
>>
>> $mw->Text(-height => 10, -width => 10)
>> ->pack(-fill => 'both', -expand =>1 );
>>
>> sub PopupMenu {
>> return [["*show", sub { $mw->deiconify } ],
>> ["hide", sub { $mw->withdraw } ],
>> ["e&xit", "exit"],
>> ];
>> }
>>
>>
>> sub Timer {
>> SetTimer(0);
>> MainLoop();
>> }
>>
>> SetTimer(0.1);
>>
>>
>> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
>> 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 [email protected]
>>
>
>
> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> 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 [email protected]
>
>
>
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 [email protected]