On 05/12/2007, Brian Millham <[EMAIL PROTECTED]> wrote: > Waldemar Biernacki wrote: > > Hello! > > > > At the end I've enclosed the little code of Perl/Win32:GUI. > > > > If you start the code you can notice that the sequence > > is the following: > > > > 1. Window appears on the screen. > > 2. An incomplete "field1" appears too. > > 3. After 2 seconds it disappears!!! for next 2 seconds and > > the field "field2" is displayed also incomplete. > > 4. At the end both fields are displayed correctly. > > > > Could anyone of you predict this disappearance looking at the code? > > If yes please let me know how to get the following sequence > > of events: > > > > 1. The first complete "field1" is displayed at the beginning. > > 2. After two seconds the second field is also displayed, > > but still the first is visible. > > > > And additional question: is this behavior (unlogical for me) > > the feature of Perl Win32::GUI or native Win32-GUI itself?
It's really the underlying Win32 implementation that causes it. A (rather simplistic) way of viewing it is that some of the drawing is done only when certain requests to re-paint a window are processed, and these requests to re-paint are only processed when a message loop is running (Win32::GUI::DoEvents() or Win32::GUI::Dialog(), among others). In your particular example you could replace the $my_window->DoEvents(); lines that Brian proposed with $my_window->Update(); and you'd see (almost) the same effect. Update() causes any outstanding paint events to be processed; DoEvents() causes ALL outstanding event (painting or otherwise) to be processed. Regards, Rob. > > > > Regards > > Waldemar > > > > I'm not sure what you are trying to do here, but if you want field1 to > show for 2 seconds, and then field2 to appear, here is the corrected > script. (There may be a better way to do this, but it's what I could > think of off the top of my head.) > > ################################# > #!/usr/bin/perl -w > > use warnings; > use strict; > > use Win32::GUI qw(); > > my $my_window = new Win32::GUI::Window ( > -name => 'my_window', > -size => [ 400, 400 ], > ); > $my_window->Show(1); > > my $field1 = $my_window->AddTextfield( > -name => 'field1', > -text => 'field1', > -pos => [ 30, 30 ], > -size => [ 100, 100 ], > ); > > $field1->SetFocus(); > $my_window->DoEvents(); # You need to DoEvents to see what you added to > the window > sleep(2); > > my $field2 = $my_window->AddTextfield( > -name => 'field2', > -text => 'field2', > -pos => [ 130, 130 ], > -size => [ 100, 100 ], > ); > > $field2->SetFocus(); > $my_window->DoEvents(); # Update the window > sleep(2); > > Win32::GUI::Dialog(); > > ################################# > > -- > Brian, Tommy, Helen and Paka -- [EMAIL PROTECTED] > This message traveled at least 44,000 miles to reach you! > > > > --- > avast! Antivirus: Outbound message clean. > Virus Database (VPS): 071205-0, 12/05/2007 > Tested on: 12/4/2007 8:34:50 PM > avast! is copyright (c) 2000-2007 ALWIL Software. > http://www.avast.com > > > > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > -- Please update your address book with my new email address: [EMAIL PROTECTED] ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/