I'll raise a bug report, as I can see no reason why there should be a difference in behaviour depending on whether there is some code to move a window before the DoModal() call.

Jez White wrote:

Hi,

Interesting one - I don't use DoModal much, but I use it like your example - it does seem odd behaviour, and I can't see any thing that is wrong. Perhaps it is a bug?

Cheers,

jez.

----- Original Message ----- From: "Robert May" <[EMAIL PROTECTED]>
To: <perl-win32-gui-users@lists.sourceforge.net>
Sent: Wednesday, March 16, 2005 9:38 PM
Subject: [perl-win32-gui-users] Possible Bug with DoModal


I've gone nearly blind looking through the source code, and can't see why I am experiencing the following behaviour. I have examined the windows generated with Spy++, and the modal window has its parent/owner set correctly, and I cannot see how the movement of the modal window before calling DoModal causes a change in behaviour.

Am I using DoModal correctly?  Does anyone else see the same problem.

Regards,
Rob.

# This shows a possible bug where a modal dialog loses its modality
# Try clicking on the close button of the main window after opening
# the modal window - the modal dialog closes, and a second click is
# need to then close the main window.  The main window should
# be disabled.
#.
# If the code to center the dialog is moved to an 'onActivate'
# callback (or removed), then it all works fine.
#
# If the modal window is also a dialog window (-dialogui => 1), then
# it's special navigation features are lost (i.e. tabbing stops working,
# return = OK does not work).
#
# Workarounds:
# (1) Don't Center (or otherwise move the dialog) before calling doModal.
#     I have resolved this by putting the Center() call in an onActivate
#     handler.
# (2) If you only have one top-level window, set the 'all' flag to 1.
#     I.e. $modal->DoModal(1).

use strict;
use warnings;

use Win32::GUI;

my $mw = Win32::GUI::Window->new(
 -title => "doModal() Bug",
 -pos => [100,100],
 -size => [200,200],
);

$mw->AddButton(
 -text => "Open Modal Window",
 -onClick => \&openModal,
);

my $modal = Win32::GUI::Window->new(
 -parent => $mw,
 -title => "Modal Window",
 -size => [100,100],
);

$mw->Show();
Win32::GUI::Dialog();
exit(0);

sub openModal
{
 # Comment out this next line to see correct behaviour
 $modal->Center($mw);

 $modal->DoModal();

 return 1;
}


-------------------------------------------------------
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://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
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