|
From: Frazier, J. J. <Joe...@Pe...> - 2001-09-05 19:37:55
|
> >4. Does anyone know a way to change the cursor during long
> >operations. I'm just looking for an hourglass, nothing fancy.
>=20
> Don't know how, but it can be done. It's Win32::GUI stuff.
>=20
> Look in the docs, or ask on the win32-gui-users mailing list=20
> if you can't=20
> get it to work. And if you need special support in The GUI=20
> Loft, just bring=20
> 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) =3D shift;
my $desk =3D $window->GetDesktopWindow();
my(undef, undef, $d_width, $d_height)=3D
Win32::GUI::GetWindowRect($desk);
my ($win_width)=3D $window->ScaleWidth();
my ($win_height) =3D $window->ScaleHeight();
my $delta_w =3D ($d_width /2) - ($win_width/ 2);
my $delta_h =3D ($d_height / 2) - ($win_height / 2);
$window->Move($delta_w, $delta_h);
}
package main;
$window =3D new Win32::GUI::Window(
-name =3D> "Window",
-topmost =3D> 1,
-icon =3D> "",
-left =3D> 300,
-top =3D> 400,
-width =3D> 205,
-height =3D> 228,
-maxsize =3D> [205,228],
-minsize =3D> [205,228],
-text =3D> "Cursor",
-maximizebox =3D> 0,
-minimizebox =3D>1,
-helpbutton =3D> 0,
);
sub Button_Click{
$CUR =3D new Win32::GUI::Cursor("c:\\winnt\\cursors\\barber.ani");
# load Cursor
$OLDCUR =3D $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); =20
# I had to put this here(why is this=20
#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 =3D> "Start",
-name =3D>"Button",
-left=3D>0,
-top=3D>4,
-width=3D>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;
}
|