窗口中有一个图像控件,另外有一个文本框控件
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
text1.Text = "X=" & Str(X) & ",  " & "Y=" & Str(Y)
End Sub这样鼠标在图像控件中移动时可以显示坐标,怎么才能让鼠标移出图像控件时,文本框清空呢??
谢谢

解决方案 »

  1.   

    Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
     Dim MouseEnter As Boolean
     MouseEnter = (0 <= X) And (X <= Picture1.Width) And (0 <= Y) And (Y <= Picture1.Height)
     If MouseEnter Then
        SetCapture Picture1.hwnd
      Else
        Text1.Text = ""
        ReleaseCapture
     End If
    End Sub