> >4.  Does anyone know a way to change the cursor during long
> >operations.  I'm just looking for an hourglass, nothing fancy.
> 
> Don't know how, but it can be done. It's Win32::GUI stuff.
> 
> Look in the docs, or ask on the win32-gui-users mailing list 
> if you can't 
> get it to work. And if you need special support in The GUI 
> Loft, just bring 
> it up here again.

here is an example:   See comments to weird stuff.  You can just change
what you don't need.  Basically, open window.  Press the button, and the
cursor changes.  A timer starts and returns the cursor after 5 seconds.

use Win32::GUI;
my $OLDCUR;

package Win32::GUI;
sub CenterOnScreen{
         my ($window) = shift;
         my $desk = $window->GetDesktopWindow();
         my(undef, undef, $d_width, $d_height)=
Win32::GUI::GetWindowRect($desk);
         my ($win_width)= $window->ScaleWidth();
         my ($win_height) = $window->ScaleHeight();
         my $delta_w = ($d_width  /2) - ($win_width/ 2);
         my $delta_h = ($d_height / 2) - ($win_height / 2);
         $window->Move($delta_w, $delta_h);
}
package main;

$window = new Win32::GUI::Window(
        -name   => "Window",
        -topmost => 1,
        -icon   => "",
        -left   => 300,
        -top    => 400,
        -width  => 205,
        -height => 228,
        -maxsize  => [205,228],
        -minsize  => [205,228],
        -text   => "Cursor",
        -maximizebox => 0,
        -minimizebox =>1,
        -helpbutton => 0,
);



sub Button_Click{
        $CUR = new Win32::GUI::Cursor("c:\\winnt\\cursors\\barber.ani");
# load Cursor
        $OLDCUR =       $window->ChangeCursor($CUR);  # set cursor
        $window->Button->Disable();  #disable button
        $window->T1->Interval(5000);  #start timer
}

sub T1_Timer{
        $window->ChangeCursor($OLDCUR);  # change cursor back
        Win32::GUI::SetCursor($OLDCUR);  
# I had to put this here(why is this 
#not an object method, but ChangeCursor is?)
# if I did not put this here, the cursor would not change until
# I moved the mouse.  Dont know why.

        $window->T1->Kill();
        $window->Button->Enable();
        print "Done\n";
}

$window->AddButton(
        -text => "Start",
        -name =>"Button",
        -left=>0,
        -top=>4,
        -width=>198,

        );
        $window->AddTimer("T1",0);
# create timer object
$window->T1->Kill();   # Kill the timer, otherwise, it fires as soon as
the dialog starts(BUG?)
$window->CenterOnScreen();  # added Method to center new windows<smile>
$window->Show();
Win32::GUI::Dialog();

###############################
###                                                        ###
###        Win32::GUI Event Subs        ###
###                                                        ###
###############################
sub Window_Terminate{
         -1;
}

Reply via email to