Results 1 to 4 of 4

Thread: Catching All MouseMove [Resolved]

  1. #1

    Thread Starter
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    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 :

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    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 .

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    Subclass the form and catch the mouse move messages the form receives

  4. #4

    Thread Starter
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    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:
    1. Private Type RECT
    2.     Left As Long
    3.     Top As Long
    4.     Right As Long
    5.     Bottom As Long
    6. End Type
    7.  
    8. Private Type POINTAPI
    9.     X As Long
    10.     Y As Long
    11. End Type
    12.  
    13. 'Declare the API-Functions
    14. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    15. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    16.  
    17. Function IsInside() As Boolean
    18.     Dim X As Long
    19.     Dim X1 As Long
    20.     Dim Y As Long
    21.     Dim Y1 As Long
    22.    
    23.    
    24.     Dim Win As RECT
    25.     Dim Cur As POINTAPI
    26.    
    27.     GetWindowRect Me.hwnd, Win
    28.     'Me.Refresh
    29.    
    30.     s = "Window Position " & vbCrLf
    31.     s = s & "Left : " & Win.Left & vbCrLf
    32.     s = s & "Right : " & Win.Right & vbCrLf
    33.     s = s & "Top : " & Win.Top & vbCrLf
    34.     s = s & "Bottom : " & Win.Bottom & vbCrLf
    35.    
    36.     GetCursorPos Cur
    37.    
    38.     s = s & "Cursor Postion" & vbCrLf
    39.     s = s & "X : " & Cur.X & vbCrLf
    40.     s = s & "Y : " & Cur.Y & vbCrLf
    41.    
    42.     'Text1.Text = s
    43.     Me.Cls
    44.     Print s
    45.    
    46.     If Cur.X > Win.Left And Cur.X < Win.Right And Cur.Y > Win.Top And Cur.Y < Win.Bottom Then
    47.         Print "Cursor Inside the Form"
    48.     Else
    49.         Print "Cursor Outside the Form"
    50.     End If
    51. End Function
    52.  
    53. Private Sub Timer1_Timer()
    54.     IsInside
    55. 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
  •  



Click Here to Expand Forum to Full Width