[开源]捕获鼠标离开事件!
'模块里声明Public Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function ReleaseCapture Lib "user32" () As Long
'窗体里标签labProInfo的MouseMove事件
Private Sub labProInfo_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseOver As Boolean
MouseOver = (0 <= X) And (X <= Me.labProInfo.Width) And (0 <= Y) And (Y <= Me.labProInfo.Height)
If MouseOver Then
Me.labProInfo.ForeColor = vbbule
SetCapture Me.labProInfo.hWnd
Else
Me.labProInfo.ForeColor = vbRed
ReleaseCapture
End If
End Sub