| Win32::GUI? I have several sleeps in my loop and I want the 
| rest of the gui
| script to be accessible while this part is "asleep". Any suggestions?

Hi Thomas

The basic knack is
Win32::GUI::DoEvents() while Win32::GUI::PeekMessage(0,0,0);

You can call this even from inside an event. Here's a complete example,
taking care of avoiding restarting the busy loop before it completed, and of
aborting the busy loop when the program terminates.

have fun,
Harald

use Win32::GUI;

$Main = new Win32::GUI::Window (-name => 'Main',
        -pos => [100, 100], -size => [400, 300]);
sub Main_Terminate {-1}

$Main->AddButton (-name => $_ = 'Click',
        -text => $_, -pos => [160, 80]);
sub Click_Click {$Main->MessageBox ("Don't do that")}

$Main->AddButton (-name => $_ = 'Busy',
        -text => $_, -pos => [160, 120]);
sub Busy_Click
{
        return 0 if $busy++;
        for ($i = 0; $i < 1e5; $i++)
        {
                print "$i\r";
                while (Win32::GUI::PeekMessage(0,0,0))
                {
                        return -1 if Win32::GUI::DoEvents() < 0;
                }
        }
        $busy = 0;
}

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

Reply via email to