Results 1 to 11 of 11

Thread: Mouse Over & Mouse Out Detection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229

    Mouse Over & Mouse Out Detection

    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.

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Inside/outside your application?

    Over what type of control?

    Please explain more...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  3. #3
    Fanatic Member Illspirit's Avatar
    Join Date
    Mar 2001
    Location
    Blackpool, England
    Posts
    815
    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:
    1. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    2. Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    3.  
    4. Private Type POINTAPI
    5.         X As Long
    6.         Y As Long
    7. End Type
    8.  
    9. Private CursorPoint As POINTAPI
    10. Private mouseX As Single
    11. Private mouseY As Single

    then use this...
    VB Code:
    1. GetCursorPos CursorPoint
    2. ScreenToClient hwnd, CursorPoint
    3. mouseX = Int(CursorPoint.X * Screen.TwipsPerPixelX)
    4. mouseY = Int(CursorPoint.Y * Screen.TwipsPerPixelX)
    5.  
    6. debug.Print "Mouse X = " & mousex & vbcrlf & "Mouse Y = " & mouseY
    Illspirit - [email protected]

    SmartBarXP Lead Developer
    SmartBarXP - The leading desktop sidebar application for Microsoft Windows XP

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Mouse Over & Mouse Out Detection

    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.
    Are you trying to create some sort of rollover image?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5
    New Member
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2

    Arrow MouseMove

    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.
    Mike Gagne
    Application Developer
    OrthoRX, Inc
    Plano, TX

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229
    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!

  7. #7
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Have a look at this... it will help you out.

    http://www.vbforums.com/showthread.p...light=rollover
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229
    Ummm...sorry but it doesn't work :S.

  9. #9
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    It works for me....
    Attached Files Attached Files
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229
    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??

  11. #11
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    If you mean to an UserControl.... sure!!
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width