Results 1 to 2 of 2

Thread: How I can detect if mouse is over the scrollbar?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    16

    How I can detect if mouse is over the scrollbar?

    Hi all. How I can detect if the mouse is over the scrollbar?

    Thx in advance.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How I can detect if mouse is over the scrollbar?

    Using timer perhaps:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type RECT
    4.    Left As Long
    5.    Top As Long
    6.    Right As Long
    7.    Bottom As Long
    8. End Type
    9.  
    10. Private Type POINTAPI
    11.     X As Long
    12.     Y As Long
    13. End Type
    14.  
    15. Private Declare Function GetCursorPos Lib "user32" _
    16.     (lpPoint As POINTAPI) As Long
    17.  
    18. Private Declare Function GetWindowRect Lib "user32" _
    19.     (ByVal hwnd As Long, lpRect As RECT) As Long
    20.  
    21. Private Sub Form_Load()
    22.     Timer1.Enabled = True
    23.     Timer1.Interval = 100 '1/10 of a second
    24. End Sub
    25.  
    26. Private Sub Timer1_Timer()
    27. '==================================
    28. Dim Rec As RECT, Point As POINTAPI
    29. Dim cbOpen As Boolean
    30.  
    31.     DoEvents
    32.     GetWindowRect HScroll1.hwnd, Rec
    33.     GetCursorPos Point
    34.    
    35.     'check if cursor is over combobox
    36.     If Point.X >= Rec.Left And Point.X <= Rec.Right And Point.Y >= Rec.Top And Point.Y <= Rec.Bottom Then
    37.         Debug.Print "MousePointer is over Horizontal Scrollbar"
    38.     Else
    39.         Debug.Print "MousePointer is outside Horizontal Scrollbar"
    40.     End If
    41.  
    42. End Sub

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