From: Harris, R. <Rob...@co...> - 2004-12-09 15:16:36
|
Mark, Your problem is much like one that I required a solution to, so using the example below I attempted a number of different resolutions, threads, api calls, process calls, in the end the resolution was much more straight forward. # Counts to 25 with an "error" at 20 # Perl v5.8.4 built for MSWin32-x86-multi-thread # Win32-GUI [1.0] Perl-Win32 Graphical User Interface Extension use Win32::GUI; use strict; my $MainWindow =3D Win32::GUI::Window->new( -text =3D> "Main", -name =3D> "MainWindow", -pos =3D> [ 200, 200 ], -size =3D> [ 150, 100 ], ); $MainWindow->AddButton( -name =3D> "OpenModal", -pos =3D> [ 15, 20 ], -text =3D> "Count to 25", ); # Moved the Modal window and button outside the sub my $ModalWindow =3D Win32::GUI::Window->new( -text =3D> "Modal", -name =3D> "ModalWindow", -pos =3D> [ 220, 220 ], -size =3D> [ 150, 100 ], -parent =3D> $MainWindow, ); my $ModalButton =3D $ModalWindow->AddButton( -name =3D> "CloseModal", -pos =3D> [ 15, 20 ], -text =3D> "dummyvaldummyval", ); my $forgotten_value =3D undef; $MainWindow->Show(); Win32::GUI::Dialog(); # This is the main dialog sequence sub OpenModal_Click { $MainWindow->Disable(); for (my $i=3D0; $i <=3D 25; $i++){ if ($i =3D=3D 20) { showmodal("Where was I again\?"); } print $i."\n"; } $MainWindow->Enable(); $MainWindow->BringWindowToTop(); } sub MainWindow_Terminate { -1; } sub showmodal { $ModalButton->Change(-text =3D> @_,); $ModalWindow->Show(); Win32::GUI::Dialog(); # This dialog sequence is specific to the modal window } sub CloseModal_Click { ModalWindow_Terminate(); } sub ModalWindow_Terminate { $forgotten_value =3D 20; $ModalWindow->Hide(); return -1; # This will terminate the modal window dialog sequence the main dialog sequence will still remain } -----Original Message----- From: per...@li... [mailto:per...@li...] On Behalf Of Mark Nettlingham Sent: Tuesday, November 30, 2004 6:34 AM To: per...@li... Subject: [perl-win32-gui-users] Awaiting modal window closure Hi all, I'm trying to implement a simple error handling subroutine, which pops up a modal error message during the main Dialog() phase. My problem is that when I call my subroutine, the modal window appears, but my script won't wait for me to close it before carrying on. I've had a bit of a fiddle, but don't want to start hacking when there's more than likely a function I've overlooked. See the code below (adapted from the modal window tutorial) TIA, Mark use Win32::GUI; $|++; $MainWindow =3D Win32::GUI::Window->new( -text =3D> "Main", -name =3D> "MainWindow", -pos =3D> [ 200, 200 ], -size =3D> [ 150, 100 ], ); $MainWindow->AddButton( -name =3D> "OpenModal", -pos =3D> [ 15, 20 ], -text =3D> "Open Modal Window", ); $MainWindow->Show(); Win32::GUI::Dialog(); sub showmodal { $errmsg =3D shift; $ModalWindow =3D Win32::GUI::Window->new( -text =3D> "Modal", -name =3D> "ModalWindow", -pos =3D> [ 220, 220 ], -size =3D> [ 150, 100 ], -parent =3D> $MainWindow, # this is the trick! ); $ModalWindow->AddButton( -name =3D> "CloseModal", -pos =3D> [ 15, 20 ], -text =3D> $errmsg, ); $MainWindow->Disable(); $ModalWindow->Show(); #Do something here to wait for modal window to be closed. } sub OpenModal_Click { print "Do stuff that generates an error\n"; showmodal("Error message"); print "I want this to happen after the modal dialog is closed\n"; } sub CloseModal_Click { $ModalWindow->Hide(); $MainWindow->Enable(); $MainWindow->BringWindowToTop(); return 1; } sub MainWindow_Terminate { -1; } sub ModalWindow_Terminate { CloseModal_Click(); return 0; # so that $ModalWindow is not destroyed } ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.=20 http://productguide.itmanagersjournal.com/ _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users=20 =20 This message may contain privileged and/or confidential = information. If you have received this e-mail in error or are not the = intended recipient, you may not use, copy, disseminate or distribute it; = do not open any attachments, delete it immediately from your system and = notify the sender promptly by e-mail that you have done so. Thank you.=20 =20 |