MouseLeaveControl Event

Applies to:  PowerForm Control
See also:  MouseEnterControl Event, MouseHoverControl Event, MouseLeaveChild Event, Event Index

The MouseLeaveControl event occurs when the mouse pointer leaves a control placed in the same container as the PowerForm control.

Syntax:

Private Sub object_MouseLeaveControl(ctl As Object)

The MouseLeaveControl event syntax has these parts:

Part Description
object The name of a PowerForm control.
ctl A reference to the control that the mouse pointer has moved away from.
Cancel A boolean value indicating whether to cancel normal processing of the MouseDown event.  Setting Cancel = True in response to a MouseDownControl event will alter the processing of normal MouseDown events, so that a double click will be interpreted by the control as a single MouseDown and other MouseDown events will be cancelled.

Remarks:

The MouseLeaveControl event is only raised if the control was added to the form at design time.  Moving the mouse pointer away from a dynamically loaded control will not generate a MouseLeaveControl event.  The MouseLeaveChild event of the Subclasser object would be better suited to that task.

The MouseLeaveControl event is only raised if the if the subclassed window does not have mouse input capture, and a MouseEnterControl event was previously raised for the same control.

By default, the PowerForm control will release mouse capture when the mouse pointer leaves the subclassed window or enters a child control.  It is possible to override this default behaviour by cancelling the MouseLeave event.  To do so, when the mouse pointer enters a child window, will disable the MouseLeaveControl event.

Example:

'Because the PowerForm control relinquishes
'mouse input capture when the mouse pointer
'enters a child control, the following example
'will not interfere with normal mouse events
'generated by controls on the form.

Option Explicit

Private Sub PowerForm1_MouseEnter()
   
'Call TrackMouse to enable the
MouseEnterControl,
    'and MouseLeaveControl events
.
    PowerForm1.TrackMouse
End Sub

Private Sub
PowerForm1_MouseEnterControl(ctl As Object)
    Debug.Print "MouseEnter " & ctl.Name
End Sub

Private Sub PowerForm1_MouseLeaveControl(ctl As Object)
    Debug.Print "MouseLeave " & ctl.Name
End Sub

Further examples:

Mouse Roll Over Using Standard Controls

 

Home

Copyright and Disclaimer