vb 获取鼠标坐标

来源:百度知道 编辑:UC知道 时间:2024/06/21 15:07:38
获取鼠标在屏幕上的坐标点,text1 = x text2 =y

建一个Timer1,Text1,Text2.
代码如下。
============
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim p As POINTAPI
Private Sub Form_Load()
Timer1.Interval = 10
End Sub

Private Sub Timer1_Timer()
GetCursorPos p
Text1.Text = p.x
Text2.Text = p.y
End Sub