Hi,

The DoModal method might be what you are looking for - from the docs:

   ###########################################################################
   # (@)METHOD:DoModal([DISABLE_ALL=FALSE])
# Enter the GUI dialog phase for a specific window: the script halts, the
   # user can interact with the window, events subroutines are triggered as
   # necessary, but no other windows in the application will accept input.
   # DoModal() also brings the window on top of all other windows.
   #
# B<DISABLE_ALL> flag can set for deactivate all top window and not only parent/active window.
   #
   # The correct usage is:
   #   $window->DoModal();
   #
   # See also Dialog()
   # See also DoEvents()

Cheers,

jez.

----- Original Message ----- From: "Mark Nettlingham" <[EMAIL PROTECTED]>
To: <perl-win32-gui-users@lists.sourceforge.net>
Sent: Tuesday, November 30, 2004 11:33 AM
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 = Win32::GUI::Window->new(
   -text => "Main",
   -name => "MainWindow",
   -pos  => [ 200, 200 ],
   -size => [ 150, 100 ],
);

$MainWindow->AddButton(
   -name => "OpenModal",
   -pos  => [ 15, 20 ],
   -text => "Open Modal Window",
);

$MainWindow->Show();
Win32::GUI::Dialog();

sub showmodal {
   $errmsg = shift;
   $ModalWindow = Win32::GUI::Window->new(
       -text => "Modal",
       -name => "ModalWindow",
       -pos  => [ 220, 220 ],
       -size => [ 150, 100 ],
       -parent => $MainWindow, # this is the trick!
   );

   $ModalWindow->AddButton(
       -name => "CloseModal",
       -pos  => [ 15, 20 ],
       -text => $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.
http://productguide.itmanagersjournal.com/
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users


Reply via email to