Is there a way to determine the mouse x and y coordinates in relation to the screen itself VS in relation to the form?
Printable View
Is there a way to determine the mouse x and y coordinates in relation to the screen itself VS in relation to the form?
if you know the x and y coords for the mouse on the form, then you should be able to use the form's Left\Top\WidthHeight properties and the screen's Height\Width properties to calculate it...???
Just use ClientToScreen API:
VB Code:
Private Type POINTAPI X As Long Y As Long End Type Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim pt As POINTAPI pt.X = X \ Screen.TwipsPerPixelX pt.Y = Y \ Screen.TwipsPerPixelY Call ClientToScreen(Text1.hwnd, pt) Debug.Print "X: " & pt.X & " Y: " & pt.Y End Sub
use the GetCursorPos API call:
HTH,Code:Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Type POINTAPI
x As Long
y As Long
End Type
Duncan