-
Hi! How can a control knows that the Mouse Pointer has just
pass, sort of a LostFocus.
I know that a MouseMove event will trigger everytime the
mouse pointer passes through a control
(PictureBox, Image..., Button etc...). I'd like to know
what event will trigger if the control just lost the
mouse pointer. Is there any... or any work around?
Thanks for any help
- I'm using VB 6.0 Enterprise Edition
-
You would have to use a timer, check for the mouseposition using Getcursorpos api and check if it's in the rect of your control, using Getwindowrect for controls with hwnd or just using the left, top, width and height properties for a image
-
No, but you could use the API calls getmousepos and getwindowrect.
If you use getwindowrect to get the rectangle of the window( that is its perimeter) you can work out if the mouse it over it or not, for this you will need a timer to monitor the cursor position and the control position, i have had to do this for one of my projects before and it did work, if you want me to mail you a demo just say.
Hope this helps,
-
Hi Again
Sorry, slight alteration to the previous messagem what i meant to say is if you get the cursor position you can then use get windowfrompoint to find the handle of the window under the mouse cursor, then compare this with the handle of your control.
Sorry about that, once again if you want a demo just say
-
Try this:
Code:
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Dim lpoint As POINTAPI
Private Sub Timer1_Timer()
GetCursorPos lpoint
Retval = WindowFromPoint(lpoint.x, lpoint.y)
'If the hWnd is the same as Command1 then...
If Retval = Command1.hwnd Then
Text1 = "It's on Command1"
Else
Text1 = "It's not on command1"
End If
End Sub
-
Thanks guys for your help!