Results 1 to 10 of 10

Thread: Vb's Mouseover

  1. #1

    Thread Starter
    Addicted Member charmedcharmer's Avatar
    Join Date
    Sep 2003
    Posts
    211

    Vb's Mouseover

    this have been bugging me ever since my Flash days, I havent heed it but now I need to ask, I hope you can help me guyz.

    Any mouseover event in VB? how?
    C++ Programming is overwhelming.

    Dont let it overwhelm you or you'll fall into the oblivion of its perfection

  2. #2
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439
    Double click whatever control you want to add the code to (or the form). On the top of the code window, click the drop down arrow of the right combo box. Click MouseOver

    Disiance

  3. #3

    Thread Starter
    Addicted Member charmedcharmer's Avatar
    Join Date
    Sep 2003
    Posts
    211
    there is no mouveover.... Only mousemove, mousedown and mouseup.
    C++ Programming is overwhelming.

    Dont let it overwhelm you or you'll fall into the oblivion of its perfection

  4. #4
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424
    MouseMove is similar to MouseOver.

  5. #5

    Thread Starter
    Addicted Member charmedcharmer's Avatar
    Join Date
    Sep 2003
    Posts
    211
    is that all it? nothing special api-related functions or something like that??
    C++ Programming is overwhelming.

    Dont let it overwhelm you or you'll fall into the oblivion of its perfection

  6. #6
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    You need to use TrackMouseEvent and subclass the window concerned to trap for WM_MOUSEHOVER

    VB Code:
    1. ' ##ENUMERATION_DESCRIPTION Before WM_MOUSEHOVER and WM_MOUSELEAVE messages can be generated for
    2. ' ##ENUMERATION_DESCRIPTION a window, the message tracking must be enabled on that window.
    3. Public Enum TrackMouseEvents
    4.     ' ##ENUMERATION_MEMBER_DESCRIPTION TME_HOVER Request WM_MOUSEHOVER message notification
    5.      TME_HOVER = &H1
    6.     ' ##ENUMERATION_MEMBER_DESCRIPTION TME_LEAVE Request WM_MOUSELEAVE message notification
    7.      TME_LEAVE = &H2
    8.     ' ##ENUMERATION_MEMBER_DESCRIPTION TME_NONCLIENT Request WM_NCMOUSEHOVER and WM_NCMOUSEHOVER messages
    9.      TME_NONCLIENT = &H10
    10.     ' ##ENUMERATION_MEMBER_DESCRIPTION TME_QUERY Get the mouse track status for this window
    11.      TME_QUERY = &H40000000
    12.     ' ##ENUMERATION_MEMBER_DESCRIPTION TME_CANCEL Cancel mouse tracking
    13.      TME_CANCEL = &H80000000
    14. End Enum
    15.  
    16. Private Type TRACKMOUSESTRUCT
    17.     cbSize As Long
    18.     dwFlags As Long '\\ TrackMouseEvents
    19.     hwndTrack As Long '\\ Target window
    20.     dwHoverTime As Long '\\ Mouse hover timeout in milliseconds
    21. End Type
    22. Private Declare Function TrackMouseEvent Lib "user32" (lpTrackMouseStruct As TRACKMOUSESTRUCT) As Long

  7. #7
    Hyperactive Member wiccaan's Avatar
    Join Date
    Apr 2004
    Location
    127.0.0.1
    Posts
    475
    Well you can try something like this, I use it with a program I have and it works perfect. I use it for a startmenu in a game I made that works like windows start menus. When you mouseover them it sets to another color background. But with other pics. Heres the module I use for it:

    Code:
    'Programmer Info: Originally developed by Jerrame Hertz
    '                 Modified and updated by Adam VanDerMeid
    '
    'Question, Comments, Suggestions? Please E-Mail [email protected]
    Option Explicit
    
    'Function found in the API Viewer
    Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    
    'Type found in the API Viewer and referenced by the GetCursorPos
    Public Type POINTAPI
            X As Long
            Y As Long
    End Type
    
    Public Function CheckMouseOver(FormName As Form, ControlName As Control, DefaultValue As Variant, MouseOverValue As Variant) As Variant
        
        'return the mouse position if the screen
        Dim MousePos As POINTAPI
        Dim RetValue As Boolean
        Dim ctrlLeft, ctrlRight, ctrlTop, ctrlBottom
        Dim frmX, frmY
            
        'Get Cursor position relevant to screen
        RetValue = GetCursorPos(MousePos)
        
        'calculate cursor position relevant to form
        frmX = MousePos.X - FormName.ScaleX(FormName.Left, vbTwips, vbPixels)
        frmY = MousePos.Y - FormName.ScaleY(FormName.Top, vbTwips, vbPixels)
            
        'calculate control dimensions relevant to form
        ctrlLeft = 3 + FormName.ScaleX(ControlName.Left, vbTwips, vbPixels)
        ctrlRight = ctrlLeft + FormName.ScaleX(ControlName.Width, vbTwips, vbPixels)
        ctrlTop = 22 + FormName.ScaleY(ControlName.Top, vbTwips, vbPixels)
        ctrlBottom = ctrlTop + FormName.ScaleY(ControlName.Height, vbTwips, vbPixels)
        
        'check cursor position against object position and return appropriate value
        If (frmX > ctrlLeft) And (frmX < ctrlRight) And (frmY > ctrlTop) And (frmY < ctrlBottom) Then
            CheckMouseOver = MouseOverValue
        Else
            CheckMouseOver = DefaultValue
        End If
    
    End Function
    Then with that I used it like this:

    Code:
    Private Sub Timer1_Timer()
    If Picture1..Visible = True Then
    Picture1.Visible = CheckMouseOver(Form1, Picture3, True, False)
    End If
    Change the code around to best fit your needs. But it does work.
    If my post was helpful please rate it

  8. #8

    Thread Starter
    Addicted Member charmedcharmer's Avatar
    Join Date
    Sep 2003
    Posts
    211
    thanks.. ill try that code later coz im not home.. thanks alot!
    C++ Programming is overwhelming.

    Dont let it overwhelm you or you'll fall into the oblivion of its perfection

  9. #9
    Member
    Join Date
    Apr 2009
    Posts
    52

    Re: Vb's Mouseover

    Yea thanks deepak sakpal

  10. #10
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Vb's Mouseover

    As long as the control exposes a hwnd property you can use Hack's code in this post.
    http://www.vbforums.com/showpost.php...57&postcount=9

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