[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Displaying hourglass, but with temporary reversion to pointer

(Mike Mitchell)

6/30/2012 6:21:00 PM

So I'm about to start a long process. I therefore set Me.Mousepointer
= vbHourGlass.

However, there's a Cancel button on the form. If I move the mouse over
the Cancel button I want the cursor to revert to a pointer as long as
the mouse remains over it.

But when the mouse is moved off the Cancel button, I want it to again
show the hourglass.

I've experimented a bit with MouseMove, but it all seems a bit
long-winded. I'd have to remember what the current pointer setting is,
in order to revert to it.

I do remember, years ago, seeing code that subclasses a button so that
you get events for MouseEnter and MouseLeave, which would seem more
sensible that MouseMove.

Any neat way of doing it?

Thanks!

MM
3 Answers

mm

7/1/2012 12:38:00 AM

0


"MM" <kylix_is@yahoo.co.uk> escribió en el mensaje
news:nkguu71hvinjvih484hf215q1f3c37mdnt@4ax.com...

May be something like this:
(It requires a command button and a timer)

Private Type POINTAPI
X As Long
Y As Long
End Type

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Private Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, lpRect As RECT) As Long

Private mMPHourGlass As Boolean

Private Sub Command1_Click()
mMPHourGlass = Not mMPHourGlass
If mMPHourGlass Then
Timer1.Enabled = True
Command1.Caption = "Cancel"
Else
Timer1.Enabled = False
Command1.Caption = "Start"
Me.MousePointer = vbDefault
End If
End Sub

Private Sub Form_Load()
Command1.Caption = "Start"
Timer1.Interval = 100
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
Dim iM As POINTAPI
Dim iR As RECT
Dim iMouseIsOnButton As Boolean

GetCursorPos iM

GetWindowRect Command1.hwnd, iR

If (iM.X > iR.Left) And (iM.X < iR.Right) Then
If (iM.Y > iR.Top) And (iM.Y < iR.Bottom) Then
Me.MousePointer = vbDefault
iMouseIsOnButton = True
End If
End If
If Not iMouseIsOnButton Then
If mMPHourGlass Then
Me.MousePointer = vbHourglass
End If
End If
End Sub


David Youngblood

7/1/2012 2:37:00 AM

0

"MM" <kylix_is@yahoo.co.uk> wrote in message
news:nkguu71hvinjvih484hf215q1f3c37mdnt@4ax.com...
> So I'm about to start a long process. I therefore set Me.Mousepointer
> = vbHourGlass.
>
> However, there's a Cancel button on the form. If I move the mouse over
> the Cancel button I want the cursor to revert to a pointer as long as
> the mouse remains over it.

If you are setting the form's MousePointer as indicated above and not the
Screen MousePointer, then you can set the command button to anything other
than default.

Me.MousePointer = vbHourglass
cmdCancel.MousePointer = vbArrow


David


(Mike Mitchell)

7/1/2012 7:07:00 AM

0

On Sat, 30 Jun 2012 21:37:25 -0500, "David Youngblood" <dwy@flash.net>
wrote:

>"MM" <kylix_is@yahoo.co.uk> wrote in message
>news:nkguu71hvinjvih484hf215q1f3c37mdnt@4ax.com...
>> So I'm about to start a long process. I therefore set Me.Mousepointer
>> = vbHourGlass.
>>
>> However, there's a Cancel button on the form. If I move the mouse over
>> the Cancel button I want the cursor to revert to a pointer as long as
>> the mouse remains over it.
>
>If you are setting the form's MousePointer as indicated above and not the
>Screen MousePointer, then you can set the command button to anything other
>than default.
>
> Me.MousePointer = vbHourglass
> cmdCancel.MousePointer = vbArrow

Ah, I thought there had to be a simple solution! Thanks.

MM