you did not call dialog() for the second window:

sub Loop_Click {

   foreach $i (0 ... 3) {
     &Show_Win2($i);
     sleep 1;
   }
Win32::GUI::Dialog();  ##add this and it works
}


-rob



David Hiltz wrote:
> 
>    Below you will a small Win32::GUI program that displays a window with a
>    button labeled "Loop".  When you click on the button it calls a
>    subroutine which should display another window with a number and an OK
>    button.  I want the program to wait between each display of the second
>    window (waiting for the user to click "OK"), but instead you see the
>    number changing and it comes to rest on the last number.
> 
>    Any ideas?
> 
>    Thanks -David Hiltz
> 
> 
> use Win32::GUI;
> 
> $Win = new Win32::GUI::Window(
>       -left   => 341,
>       -top    => 218,
>       -width  => 300,
>       -height => 213,
>       -name   => "Win",
>       -text   => "Window Title"
>       );
> 
> $Win->Show();
> 
> $Win->AddButton(
>        -text    => "Loop",
>        -name    => "Loop",
>        -left    => 104.5,
>        -top     => 102,
>        -width   => 95,
>        -height  => 28,
>       );
> 
> $Win2 = new Win32::GUI::Window(
>       -left   => 391,
>       -top    => 238,
>       -width  => 200,
>       -height => 183,
>       -name   => "Win2",
>       -title   => "New Window",
>       );
> 
> $Win2->AddLabel(
>        -text    => "",
>        -name    => "Label",
>        -left    => 60,
>        -top     => 30,
>        -width   => 20,
>        -height  => 20,
>       );
> 
> $Win2->AddButton(
>        -text    => "OK",
>        -name    => "OK",
>        -left    => 50,
>        -top     => 102,
>        -width   => 95,
>        -height  => 28,
>       );
> 
> Win32::GUI::Dialog();
> 
> sub Win_Terminate {
>    return -1;
> }
> 
> sub OK_Click {
>    $Win2->Hide();
> }
> 
> sub Loop_Click {
> 
>    foreach $i (0 ... 3) {
>      &Show_Win2($i);
>      sleep 1;
>    }
> }
> 
> sub Show_Win2 {
>    my($num) = @_;
> 
>    $Win2->Label->Text($num);
>    $Win2->Show();
>    $Win2->Update();  # This will make the OK button show up, but
>                      # the window will not wait for a click of the OK.
> }

Reply via email to