No Problem, There's 2 APIs to use
they all use
Code:
Private Type POINTAPI
x As Long
y As Long
End Type
which is a type used to store the mouse position
the first is
Code:
Private Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
this fills the structure passed to lpPoint with the coordinates of the mouse on the screen
the other one is
Code:
Private Declare Function ScreenToClient Lib "user32" Alias "ScreenToClient" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
this translates the coordinates in lpPoint from screen coods to the coords of a particular window.
The coords of the mouse position you get are in pixels, you need the scalex and scaley methods to translate this into twips.
for example
Code:
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim px As Single
Dim py As Long
Dim apiPoint As POINTAPI
GetCursorPos apiPoint 'gets the screen position of the cursor in pixels
ScreenToClient Form1.hwnd, apiPoint 'Tanslates to window coords, still in pixels
px = Form1.ScaleX(apiPoint.x, vbPixels, vbTwips) 'scales coords to pixels
py = Form1.ScaleY(apiPoint.y, vbPixels, vbTwips)
MsgBox x - px 'will always return 0
MsgBox y - py
End Sub
hope this helps