RE: [perl-win32-gui-users] HOWTO: Modal windows
At 10:08 2002-10-22 +1000, Rogers, John wrote: note that this function must be called without ANY parameter or instantiation (eg. don't call it as method of a created object): Win32::GUI::Dialog(); # correct $Window-Dialog();# !!!WRONG!!! So, it's not an un-documented feature, it's a documented un-feature. I'll go get that Doh! now :) /J -- --- -- -- -- -- - - - Johan LindströmSourcerer @ Boss Casinos [EMAIL PROTECTED] Latest bookmark: XEmacs XEmacs and Supporting Libraries and Prog... http://xemacs.org/Download/win32/ dmoz: /Computers/Open_Source/Software/Editors/ 98
Re: [perl-win32-gui-users] HOWTO: Modal windows
Johan Lindstrom wrote: At 10:08 2002-10-22 +1000, Rogers, John wrote: note that this function must be called without ANY parameter or instantiation (eg. don't call it as method of a created object): Win32::GUI::Dialog(); # correct $Window-Dialog();# !!!WRONG!!! So, it's not an un-documented feature, it's a documented un-feature. I'll go get that Doh! now :) well, this is a very tricky point. in fact, you can do $Window-Dialog() (there is very little that you can't do), but it's just that *usually*, *most of the times*, this is not what you want. I was using $Window-Dialog() and it seemed to work fine, until I implemented Comboboxes. drop-down Comboboxes use their own windows, so if you have a drop-down Combobox in your $Window and you called $Window-Dialog, the drop-down box will not show at all (it will be blank and unresponsive to user input). so I stated that doing $Window-Dialog is wrong, because it produces undesiderable effects. however, if you are not using drop-down Comboboxes, this may be just what you want ;-) cheers, Aldo __END__ $_=q,just perl,,s, , another ,,s,$, hacker,,print;
[perl-win32-gui-users] HOWTO: Modal windows
Aaaarggg!!! I started poking around in GUI.xs, looking for a solution to my double event problem, and found the mother of all undocumented features: True modal dialog boxes in Win32::GUI. Well very close anyway... I _always_ thought this wasn't possible. Heck, I even wrote Win32::GUI::Modalizer just to hack (and it is a sorry hack) around that absent feature. In the event that this is common knowledge and I'm the only one who didn't get this obvious thing, I have already prepared a big Doh! for myself :) If not, this is how to do it. Test the script below. What I found was that Win32::GUI::Dialog accepts a hwnd parameter. So you don't have to call it like this: Win32::GUI::Dialog(); you can also call it like this: $win-Dialog(); and then the event loop is restricted to $win, which means other windows don't get processed. There are still a few things not 100% correct with this: - Your windows aren't really connected to the modal window. This is only noticable when you switch between other applications and your GUI program, in that they don't get moved on top of the other application when your modal window gets focus again. - There seems to be some problem with mouse events when clicking in the main window, and then clicking on the title bar on your modal window (the modal window jumps to a new location relative to the previous click. this is obviously wrong). Apart from that it seems to work. This goes for 0.0.558. Can someone confirm this behaviour with 0.0.665? In brief: - Call it like $win-Dialog(); - In the Terminate event, or a close-button Click event, Hide() the modal window and return -1 to break out of the main loop. The modal window isn't destroyed. - You can also make a MessageBox modal to a window like this: $winModeless-MessageBox(Clicked the Test button, Test); #!/usr/local/bin/perl -w use strict; use Win32::GUI; my $winModeless = new Win32::GUI::Window( -left = 13, -top= 32, -width = 439, -height = 260, -name = winModeless, -text = Win32::GUI::Modalizer Synopsis [1] ); $winModeless-AddButton( -text= Open, -name= btnModelessOpen, -left= 358, -top = 207, -width = 70, -height = 21, ); $winModeless-AddButton( -text= Test, -name= btnModelessTest, -left= 358, -top = 20, -width = 70, -height = 21, ); my $winModeless2 = new Win32::GUI::Window( -left = 100, -top= 100, -width = 439, -height = 260, -name = winModeless2, -text = Win32::GUI::Modalizer Synopsis [2] ); my $winDialog = new Win32::GUI::DialogBox( -left = 50, -top= 50, -width = 439, -height = 260, -name = winDialog, -text = Dialog Box, ); $winDialog-AddButton( -text= Ok, -name= btnDialogOk, -left= 358, -top = 207, -width = 70, -height = 21, ); $winModeless-Show(); $winModeless2-Show(); #Go modal Win32::GUI::Dialog(); ##Event handlers #Modeless window sub winModeless_Terminate { return(-1); } sub btnModelessOpen_Click { $winDialog-Show(); $winDialog-Dialog(); return(1); } sub btnModelessTest_Click { $winModeless-MessageBox(Clicked the Test button, Test Button); return(1); } #Modeless2 window sub winModeless2_Terminate { return(-1); } #Dialog window sub winDialog_Terminate { $winDialog-Hide(); return -1; } sub btnDialogOk_Click { $winDialog-Hide(); print Ok\n; return(-1); } __END__ /J -- --- -- -- -- -- - - - Johan LindströmSourcerer @ Boss Casinos [EMAIL PROTECTED] Latest bookmark: XEmacs XEmacs and Supporting Libraries and Prog... http://xemacs.org/Download/win32/ dmoz: /Computers/Open_Source/Software/Editors/ 98
RE: [perl-win32-gui-users] HOWTO: Modal windows
Johan, I tested your script with 0.0.665 on Win2k, Works as you describe, shame about the jumping though. I used to call Dialog this way, (ignorant of modal I admit) then I read methods.html in the docs which states, note that this function must be called without ANY parameter or instantiation (eg. don't call it as method of a created object): Win32::GUI::Dialog(); # correct $Window-Dialog();# !!!WRONG!!! Perhaps Mr Calpini , chose to hide this feature because it still had problems ?? John R -Original Message- From: Johan Lindstrom [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 22, 2002 6:51 AM To: perl-win32-gui-users@lists.sourceforge.net Subject: [perl-win32-gui-users] HOWTO: Modal windows Aaaarggg!!! I started poking around in GUI.xs, looking for a solution to my double event problem, and found the mother of all undocumented features: True modal dialog boxes in Win32::GUI. Well very close anyway... I _always_ thought this wasn't possible. Heck, I even wrote Win32::GUI::Modalizer just to hack (and it is a sorry hack) around that absent feature. In the event that this is common knowledge and I'm the only one who didn't get this obvious thing, I have already prepared a big Doh! for myself :) If not, this is how to do it. Test the script below. What I found was that Win32::GUI::Dialog accepts a hwnd parameter. So you don't have to call it like this: Win32::GUI::Dialog(); you can also call it like this: $win-Dialog(); and then the event loop is restricted to $win, which means other windows don't get processed. There are still a few things not 100% correct with this: - Your windows aren't really connected to the modal window. This is only noticable when you switch between other applications and your GUI program, in that they don't get moved on top of the other application when your modal window gets focus again. - There seems to be some problem with mouse events when clicking in the main window, and then clicking on the title bar on your modal window (the modal window jumps to a new location relative to the previous click. this is obviously wrong). Apart from that it seems to work. This goes for 0.0.558. Can someone confirm this behaviour with 0.0.665? In brief: - Call it like $win-Dialog(); - In the Terminate event, or a close-button Click event, Hide() the modal window and return -1 to break out of the main loop. The modal window isn't destroyed. - You can also make a MessageBox modal to a window like this: $winModeless-MessageBox(Clicked the Test button, Test); #!/usr/local/bin/perl -w use strict; use Win32::GUI; my $winModeless = new Win32::GUI::Window( -left = 13, -top= 32, -width = 439, -height = 260, -name = winModeless, -text = Win32::GUI::Modalizer Synopsis [1] ); $winModeless-AddButton( -text= Open, -name= btnModelessOpen, -left= 358, -top = 207, -width = 70, -height = 21, ); $winModeless-AddButton( -text= Test, -name= btnModelessTest, -left= 358, -top = 20, -width = 70, -height = 21, ); my $winModeless2 = new Win32::GUI::Window( -left = 100, -top= 100, -width = 439, -height = 260, -name = winModeless2, -text = Win32::GUI::Modalizer Synopsis [2] ); my $winDialog = new Win32::GUI::DialogBox( -left = 50, -top= 50, -width = 439, -height = 260, -name = winDialog, -text = Dialog Box, ); $winDialog-AddButton( -text= Ok, -name= btnDialogOk, -left= 358, -top = 207, -width = 70, -height = 21, ); $winModeless-Show(); $winModeless2-Show(); #Go modal Win32::GUI::Dialog(); ##Event handlers #Modeless window sub winModeless_Terminate { return(-1); } sub btnModelessOpen_Click { $winDialog-Show(); $winDialog-Dialog(); return(1); } sub btnModelessTest_Click { $winModeless-MessageBox(Clicked the Test button, Test Button); return(1); } #Modeless2 window sub winModeless2_Terminate { return(-1); } #Dialog window sub winDialog_Terminate { $winDialog-Hide(); return -1; } sub btnDialogOk_Click { $winDialog-Hide(); print Ok\n; return(-1); } __END__ /J -- --- -- -- -- -- - - - Johan LindströmSourcerer @ Boss Casinos [EMAIL PROTECTED] Latest bookmark: XEmacs XEmacs and Supporting Libraries and Prog... http://xemacs.org/Download