’申明API函数—— Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long
’通过Text1的MouseMove事件判断鼠标指针位置 Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseLeave As Boolean
MouseLeave = (0 <= X) And (X <= Text1.Width) And (0 <= Y) And (Y <= Text1.Height)
If MouseLeave Then Text1 = "Inside" SetCapture Text1.hWnd