vb 鼠标坐标 不要print 就是随着鼠标移动改变

来源:百度知道 编辑:UC知道 时间:2024/05/29 07:04:07
可不可以在鼠标附近直接出现坐标数字 不用print

Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Sub Command1_Click()
Dim p As POINTAPI
GetCursorPos p
label1.move p.x,p.y
label.caption = "x=" & p.x & ", y=" & p.y
End Sub

先加入一个LABEL控件
代码
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Label1
.Caption = Str(X) + "," + Str(Y)
.Top = Y
.Left = X
End With
End Sub