|
-
Mar 25th, 2000, 08:26 AM
#1
Thread Starter
Fanatic Member
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
-
Mar 25th, 2000, 05:09 PM
#2
transcendental analytic
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
-
Mar 25th, 2000, 10:32 PM
#3
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|