vb怎么使用api获取鼠标的位置信息呢?
3个回答
展开全部
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) '点击窗体运行
Dim p As POINTAPI
GetCursorPos p
MsgBox "当前鼠标相对于窗口的所在位置:(" & X \ Screen.TwipsPerPixelX & "," & Y \ Screen.TwipsPerPixelY & ")" & vbCrLf & "相对于屏幕的所在位置:(" & p.X & "," & p.Y & ")"
End Sub
展开全部
Option Explicit
Type POINTAPI
x As Long
y As Long
End Type
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Option Explicit
Private Sub Command1_Click()
Dim point As POINTAPI
GetCursorPos point
MsgBox "(x,y)=(" & point.x & "," & point.y & ")", , "Êó±êλÖÃ"
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询