Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Command1_Click()
Command1.Tag = ""
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Command1.Tag = "In" Then
If X < 0 Or Y < 0 Or X > Command1.Width Or Y > Command1.Height Then
Command1.Tag = ""
ReleaseCapture
Command1.Caption = "离开"
End If
Else
Command1.Tag = "In"
SetCapture Command1.hwnd
Command1.Caption = "进入"
End If
End Sub
|