使命召唤7谷歌:怎样用 vb 取得鼠标在窗口中的坐标?

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/11 15:54:38

思路是:当在窗体中单击,且松开鼠标键后,在Text1,Text2中分别显示鼠标在窗体中的位置的X,Y的值

Dim strSF As Boolean

Private Sub Form_Load()
strSF = False
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
strSF = True
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If strSF = True Then
Text1.Text = X
Text2.Text = Y
strSF = False
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1 = X
Text2 = Y
End Sub

上面两位一位是移动鼠标显示位置,一位的办法是点击鼠标后显示位置