|
-
Jan 24th, 2004, 11:58 AM
#1
Catching All MouseMove [Resolved]
Hi,
How can I detect any mouse movent inside my vb apps, without having to write code in mouse event for each control in my form. As those controls will cover the form and as a result mousmove for the form will not be fired.
Is there a way i could achieve that without having to disable mouse even of other controls in my form?
Just need a pointer towards the solution. I dont mind if have to use API or subclassing.
Thanks in advance.
Danial
Last edited by Danial; Jan 24th, 2004 at 05:32 PM.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jan 24th, 2004, 12:00 PM
#2
The picture isn't missing
no, but you can temporarily make it so by using SetCapture, or you could use a timer that checks if the mouse is inside the form.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jan 24th, 2004, 12:45 PM
#3
Subclass the form and catch the mouse move messages the form receives
-
Jan 24th, 2004, 01:07 PM
#4
Originally posted by BuggyProgrammer
no, but you can temporarily make it so by using SetCapture, or you could use a timer that checks if the mouse is inside the form.
Thanks for the pointer, I have sloved it usign the two API GetWindowRect and GetCursorPos.
Here is the example if any one else reading this is interested :
VB Code:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End Type
'Declare the API-Functions
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Function IsInside() As Boolean
Dim X As Long
Dim X1 As Long
Dim Y As Long
Dim Y1 As Long
Dim Win As RECT
Dim Cur As POINTAPI
GetWindowRect Me.hwnd, Win
'Me.Refresh
s = "Window Position " & vbCrLf
s = s & "Left : " & Win.Left & vbCrLf
s = s & "Right : " & Win.Right & vbCrLf
s = s & "Top : " & Win.Top & vbCrLf
s = s & "Bottom : " & Win.Bottom & vbCrLf
GetCursorPos Cur
s = s & "Cursor Postion" & vbCrLf
s = s & "X : " & Cur.X & vbCrLf
s = s & "Y : " & Cur.Y & vbCrLf
'Text1.Text = s
Me.Cls
Print s
If Cur.X > Win.Left And Cur.X < Win.Right And Cur.Y > Win.Top And Cur.Y < Win.Bottom Then
Print "Cursor Inside the Form"
Else
Print "Cursor Outside the Form"
End If
End Function
Private Sub Timer1_Timer()
IsInside
End Sub
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|