Results 1 to 3 of 3

Thread: Mouse_Move Event - ???

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Is there a way to extend the mouse_move event beyond the current project? In other word, does anyone know how to enhance the mouse_move event inorder to detect other applications as well.

    You codes will be appreciated!

    Thank You

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    A simple solution would be to use some API. GetCursorPos gets the position of the cursor and SetCursorpos moves it. Copy this into a module and you can get the cursor position on the screen whenever you want. Use the cursorX and cursorY properties like any other integer var.

    Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
    Type POINTAPI
    X As Long
    Y As Long
    End Type
    Dim pnt As POINTAPI
    Property Get cursorX() As Integer
    temp = GetCursorPos(pnt)
    cursorX = pnt.X
    End Property
    Property Get cursorY() As Integer
    temp = GetCursorPos(pnt)
    cursorY = pnt.Y
    End Property
    Property Let cursorX(newvalue As Integer)
    temp = SetCursorPos(newvalue, cursorY)
    End Property
    Property Let cursorY(newvalue As Integer)
    temp = SetCursorPos(cursorX, newvalue)
    End Property

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089

    Better but more complicated

    If you use a timer to check the mouse position using keadmans code more than likley all sorts of things will start flashing annoyingly(they might not but they might)

    better are the setcapture and relese capture APIs

    setcapture will send all mouse events to one window/control, eg your form, it's a fairly self explanitory function,hWnd is the window handle of the window you want. you can stop this with releasecapture which takes no arguments.

    in order to get mouseevents firing as normal on other controls while you have the mouse captured you will have to subclass your capturing window, if you get any mouse event, use the getcursorpos API to get the mouse position and the window from point API to get the window the mouse is ofer and redirect the message to tat window using callWindowproc and get window long, remembering to return the correct value from your function.

    put your mousemove code in this module by trapping the relevand messages.

    Hope this helps.

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