VB Code:
Option Explicit Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function GetCapture Lib "user32" () As Long Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) With Command1 If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then 'MouseLeave Call ReleaseCapture ElseIf GetCapture() <> .hwnd Then 'MouseEnter Call SetCapture(.hwnd) Else 'Normal MouseMove End If End With End Sub
Replace Command1 with the name of the control. The control must have an hWnd property, and support the MouseMove event for this to work.
![]()




Reply With Quote