Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If 0 <= X And X <= Command1.Width And 0 <= Y And Y <= Command1.Height Then SetCapture Command1.hWnd '指针进入控件的事件 Else ReleaseCapture '指针离开控件的事件 End If End Sub