How do I get an hourglass mouse pointer to show up?

How do I get an hourglass mouse pointer to show up?

Anonymous
Not applicable
538 Views
2 Replies
Message 1 of 3

How do I get an hourglass mouse pointer to show up?

Anonymous
Not applicable
Hi all,

I want to get the mouse pointer property for a form to change to an
hourglass during a time extensive operation. If I set the property

FormMain.MousePointer = fmMousePointerHourGlass

do a bunch of stuff

FormMain.MousePointer = fmMousePointerDefault

the pointer does not change.

I have tried to force a change by hiding / showing the form but this sets me
off into space and I have to cancel the app to get out. I have also tried
the refresh method for the for but this didn't work either. I am sure there
is some simple way to make this happen but I don't have time to (*&%$&
around for hours to find it. Any help would be appreciated.

Thanks,
Will
0 Likes
539 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Hi Will,
You need to let the system process events and update the screen, by adding
DoEvents. Let's say I had a small form with two command buttons, one that
started a loop, and the other to stop the loop (by setting my boolean test
variable to true), changing the forms mouse pointer would look something
like this:

Option Explicit
Public blnCancel As Boolean

Private Sub UserForm_Initialize()
CommandButton1.Caption = "Start"
CommandButton2.Caption = "Cancel"
End Sub

Private Sub CommandButton1_Click()
'Begin a loop, but first change the
'Pointer
Me.MousePointer = fmMousePointerHourGlass
Do Until blnCancel
'Allow the system to process the queue
DoEvents
'So that things like mouse pointers
'Can be set
Loop
Me.MousePointer = fmMousePointerDefault
End Sub

Private Sub CommandButton2_Click()
blnCancel = True
End Sub

Randall Rath
VB Design
Drop by our message board at
http://www.vbdesign.net/beans/
for help with your VBA questions!
0 Likes
Message 3 of 3

Anonymous
Not applicable
How do I add to your peanuttiness?...I used this in a routine and it works
great, but If I run the same sub twice in a row the hour glass doesn't
appear the second time through the routine. So I added the following
statement (blnCancel = False) to the sub:

Private Sub CommandButton1_Click()
blnCancel = False
'Begin a loop, but first change the
'Pointer
Me.MousePointer = fmMousePointerHourGlass
Do Until blnCancel
'Allow the system to process the queue
DoEvents
'So that things like mouse pointers
'Can be set
Loop
Me.MousePointer = fmMousePointerDefault
End Sub

Viola, hourglass appears on every "start" click!

Question? How would this routine look if it was implemented as a class?

RLB

"Randall Rath" wrote in message
news:B4A0351246B2B898C2B2F58D3DCBE82F@in.WebX.maYIadrTaRb...
> Hi Will,
> You need to let the system process events and update the screen, by adding
> DoEvents. Let's say I had a small form with two command buttons, one that
> started a loop, and the other to stop the loop (by setting my boolean test
> variable to true), changing the forms mouse pointer would look something
> like this:
>
> Option Explicit
> Public blnCancel As Boolean
>
> Private Sub UserForm_Initialize()
> CommandButton1.Caption = "Start"
> CommandButton2.Caption = "Cancel"
> End Sub
>
> Private Sub CommandButton1_Click()
> 'Begin a loop, but first change the
> 'Pointer
> Me.MousePointer = fmMousePointerHourGlass
> Do Until blnCancel
> 'Allow the system to process the queue
> DoEvents
> 'So that things like mouse pointers
> 'Can be set
> Loop
> Me.MousePointer = fmMousePointerDefault
> End Sub
>
> Private Sub CommandButton2_Click()
> blnCancel = True
> End Sub
>
> Randall Rath
> VB Design
> Drop by our message board at
> http://www.vbdesign.net/beans/
> for help with your VBA questions!
>
0 Likes