Hi, does anyone know of a good way to detect mouse over and mouse out? Please tell me every possible way to do so because I wanna see which is the fastest. Thank you.
Printable View
Hi, does anyone know of a good way to detect mouse over and mouse out? Please tell me every possible way to do so because I wanna see which is the fastest. Thank you.
Inside/outside your application?
Over what type of control?
Please explain more...:confused:
well u can find the position of the mouse. u could use this in a loop to find out if it is over the control?
declare this...
VB Code:
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long Private Type POINTAPI X As Long Y As Long End Type Private CursorPoint As POINTAPI Private mouseX As Single Private mouseY As Single
then use this...
VB Code:
GetCursorPos CursorPoint ScreenToClient hwnd, CursorPoint mouseX = Int(CursorPoint.X * Screen.TwipsPerPixelX) mouseY = Int(CursorPoint.Y * Screen.TwipsPerPixelX) debug.Print "Mouse X = " & mousex & vbcrlf & "Mouse Y = " & mouseY
Are you trying to create some sort of rollover image?Quote:
Originally posted by INF3RN0666
Hi, does anyone know of a good way to detect mouse over and mouse out? Please tell me every possible way to do so because I wanna see which is the fastest. Thank you.
MouseMove is the method used to do this. To detect MouseOut events, just use the MouseMove methods on the Form that the controls lies on. That's what I've always done.
Thank you for all your help, it's greatly appreciated.
I'll explain what I would like to do in order to get the best sollution. Also I didn't have time posting this thread before and then my Enter Button got stuck and posted 5 threads.
What I'm trying to develop is a Command Button for a big project. This button changes to a user specified color on Mouse Over and returns to the user specified color on Mouse Out. It has other features also, but I won't get into that. Well, I'm going to use this button alot so I'd like the most resource efficient code because programming this entire application in VC++ would be a hassle.
I'll talk about the problem with the MouseMove Event. If the user moves his mouse over the item very quickly and then off the form, it will freeze in the highlighted position. Second of all, there is much coding to be done that way especially with that many controls on one form.
I've seen examples of the Mouse Position API. I'd prefer this way because it's fast and depends on less coding. Then again, I've only seen it run off timers and when there are 30 of these things on one form, that will be a problem. So how would I implement this but in the best way possible?
Thanks once again for your help!
Have a look at this... it will help you out.
http://www.vbforums.com/showthread.p...light=rollover
Ummm...sorry but it doesn't work :S.
It works for me....
Oh ok...That's weird. Well can you add that code to a control you're making and then add the control to a form??
If you mean to an UserControl.... sure!!