Is there a way I can intercept a form based event from inside a usercontrol?
Ie: Snag the mouse move event for the form from inside a usercontrol?
EireDrake
Printable View
Is there a way I can intercept a form based event from inside a usercontrol?
Ie: Snag the mouse move event for the form from inside a usercontrol?
EireDrake
Are you making a rollover effect?
Basically I'm trying to detect when the mouse is over the control or over the form from within the control...
I'm basically trying to create a Command Button which highlights it's text when the cursor is over it OR changes it's image when the cursor is over it.
And yes I know that there are controls already out there but I have some specifications I want in the control. So what I need to be able to do is detect when the Mouse Cursor is no longer over the control in order to let the control know when to switch back. I'd prefer to avoid using the mouse API's because I don't feel like having to compute the control position based on the screen.
Ie: Usercontrol_Mouse_Move(blah)
Text1.forecolor=VBRED
end
Form1_Mouse_Move(Blah)
text1.forecolor=VBBLACK
end
I'm confused... Why would you like to avoid api as i have the perfect solution for you, using it?
Don't get me wrong... ANY solution is better than no solution. I was just hoping there was a way to do it without an API...Whatcha got? I'll put it to use if it's what I'm looking for...
Thanks,
EireDrake
Of course you can do it without api, but never as a usercontrol, you have to subclass and ****.
No, you have to get the mouseposition and the usercontrol wnd's Rect. using these:
Get the wnd of your usercontrol and get it's rect, then get the mousecursor pointapi and compare the it with the rect and see if they fit, if not, you're mouse exiting - this has to be done in a timer. Turn of the timer when your mouse exits and when it enters by triggering mousemove event, you enable the timer again.Code:Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) As Long
Type POINTAPI
x As Long
y As Long
End Type
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type