Programming » Visual Basic 6 » Visual Basic 6 Code » Mouse » ");?>
Simulates an exit event for the mouse.
'Put this in a module:
'//*********************************//'
Public Declare Function SetCapture Lib "user32" (ByVal hwnd As LongAs Long
Public Declare Function ReleaseCapture Lib "user32" () As Long


'Put this in the mouse_move event of your control:
'//*********************************//'

    With cmdButton  'Change this to the name of the control

       If Button = 0 Then

          If (x < 0) Or (y < 0) Or (x > .Width) Or (y > .Height) Then
              'Mouse pointer is outside button, so let other controls receive
              'mouseevents too:
              ReleaseCapture

              ' Do your 'mouse-exit' stuff here

          Else
              ' Mouse pointer is over button, so we'll capture it, thus
              ' we'll receive mouse messages even if the mouse pointer is
              ' not over the button
              SetCapture .hwnd

              ' Do your 'mouse-enter' stuff here

          End If
       End If
    End With