7,763
社区成员
发帖
与我相关
我的任务
分享
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 Picture1_DblClick()
Dim pt As POINTAPI, pt2 As POINTAPI
Dim cx As Long, cy As Long
If GetCursorPos(pt) Then
pt2 = pt
Debug.Print "当前鼠标相对屏幕坐标: " & pt.X & "," & pt.Y; " 像素."
If ScreenToClient(Form1.hWnd, pt) Then
Debug.Print "当前鼠标相对窗体坐标: " & pt.X & "," & pt.Y; " 像素."
cx = Form1.ScaleX(pt.X, vbPixels, vbTwips)
cy = Form1.ScaleY(pt.Y, vbPixels, vbTwips)
Debug.Print "当前鼠标相对窗体坐标: " & cx & "," & cy; " 缇."
End If
If ScreenToClient(Picture1.hWnd, pt2) Then
Debug.Print "当前鼠标相对图片框坐标: " & pt2.X & "," & pt2.Y; " 像素."
cx = Picture1.ScaleX(pt2.X, vbPixels, vbTwips)
cy = Picture1.ScaleY(pt2.Y, vbPixels, vbTwips)
Debug.Print "当前鼠标相对图片框坐标: " & cx & "," & cy; " 缇."
End If
End If
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print X & "/" & Y
End Sub