Mouse movements in form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DanAusitn
    New Member
    • Jun 2007
    • 15

    #1

    Mouse movements in form

    Good morning folk,

    a quick question to anyone who can help.

    i am working on a program and i am using the below code to simulate mouse movement to certain
    co-ords, but the thing is the co-ords 0 , 0 refer to the position at the very top left of the monitor.
    what i want is for the co-ords 0 , 0 to refer to the top left in my form so the mouse clicks and
    movements stay inside the form.






    Here is the code:


    Code:
    Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Public Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
    Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Public Type PointAPI
        x As Long
        y As Long
    End Type
    Public Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    any help will be much appriciated

    Thanks

    Danausitn
  • DanAusitn
    New Member
    • Jun 2007
    • 15

    #2
    do i have to set my active form as an object ? and then make the active selection my form or something ?

    Comment

    • hariharanmca
      Top Contributor
      • Dec 2006
      • 1977

      #3
      Originally posted by DanAusitn
      do i have to set my active form as an object ? and then make the active selection my form or something ?
      i think you are looking for


      [CODE=vb]Private Sub Form_MouseMove( Button As Integer, Shift As Integer, X As Single, Y As Single)

      End Sub[/CODE]

      In the above form mouse move event you can get form mouse X and Y position in X As Single, Y As Single parameters.

      Comment

      Working...