smithgr
asked on
How to use GetCursorPos
I need to find the X, and Y coordinate position of the mouse on the screen (Whether its on my form or not) how can I do this using the API? I have searched but do not understand the API calls...Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
MIke, this is great and I have it working...do you know how to tell what the left and top of a form are using the same type of coordinates? What I'm trying to do is to find if the mouse is outside of my form...Thanks
Sorry it took me so long to respond:
Dim nX as single
Dim nY as single
nX=P.X/Screen.TwipsPerPixe lX
nY=P.Y/Screen.TwipsPerPixe lY
Dim nX as single
Dim nY as single
nX=P.X/Screen.TwipsPerPixe
nY=P.Y/Screen.TwipsPerPixe
ASKER
Thanks once again Mike!
Type POINTAPI
x As Long
y As Long
End Type
Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Now, to get the cursor location, use:
Dim p as POINTAPI
Dim X as long
X=GetCursorPos(p)
'p.X and p.Y will hold the coordinates