单机版cs下载:[VB]鼠标移上去后显示不出座标值?

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/09 10:37:58
选MouseMove后,函数体为
Cls
Me.CurrentX=Me.ScaleWidth/4
Me.CurrentY=Me.ScaleHeight/2
print"";X;Y
运行,模块上显示不出来....

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI '定义点(Point)结构
X As Long '点在X坐标(横坐标)上的坐标值
Y As Long '点在Y坐标(纵坐标)上的坐标值
End Type
Sub PrintCursorPos()
Dim dl As Long
Dim MyPoint As POINTAPI
dl& = GetCursorPos(MyPoint) '调用函数,获取屏幕鼠标坐标
'Debug.Print "X=" & Str(MyPoint.X) & " and " & "Y=" & Str(MyPoint.Y)
Label1.Caption = "当前横坐标:" & Str(MyPoint.X)
Label2.Caption = "当前纵坐标:" & Str(MyPoint.Y)
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
PrintCursorPos
End Sub