• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 399
  • Last Modified:

MouseMove on webbrowser1

How can I find out if the mouse is on webbrowser1?
0
derekcmartin
Asked:
derekcmartin
  • 3
  • 2
1 Solution
 
VBGuruCommented:
Have timer control and a webbrowser control, copy and paste the following piece of code.

Private Type POINTAPI
    x As Long
    y As Long
End Type
Dim P As POINTAPI
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Sub Form_Load()
Timer1.Interval = 200
End Sub

Private Sub Timer1_Timer()
    P.x = 0
    P.y = 0
    GetCursorPos P
    'Get information about the form's left and top
    ScreenToClient hwnd, P
    If P.x >= WebBrowser1.Left And P.x <= WebBrowser1.Left + WebBrowser1.Width And P.y >= WebBrowser1.Top And P.y <= WebBrowser1.Top + WebBrowser1.Height Then
        msgbox "Cursor on the webbrowser control"
    End If
End Sub
0
 
derekcmartinAuthor Commented:
Adjusted points from 70 to 100
0
 
derekcmartinAuthor Commented:
Thanks a lot, it works great!
0
 
derekcmartinAuthor Commented:
I increased the points because you were so quick to respond, and it works excellent!
0
 
VBGuruCommented:
thank you for the points
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now