MouseEnterChild Event

Applies to:  Subclasser object
See also:  

The MouseEnterChild event occurs when the subclassed window has captured mouse input, and the mouse pointer moves into a child window of the subclassed window.

Syntax:

Private Sub object_MouseEnterChild(ByVal hWndChild As Long)

The MouseDownChild event syntax has these parts:

Part Description
object The name of a SubClasser object, declared using WithEvents.
hWndChild The handle of the child window into which the mouse pointer has moved.

Remarks:

The MouseEnterChild event is only raised if the subclassed window has captured mouse input.  To enable the MouseEnterChild event, call TrackMouse in the MouseEnter event.

The subclassed window will lose mouse capture when the mouse pointer enters a child window.  However, this will not prevent a MouseLeaveChild event from being raised when the mouse pointer re-enters the subclassed window.

Example:

'Because the Subclasser object 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 Form_Load()
    Set objmSubclasser = SubClassWindow(hWnd)
End Sub

Private Sub objmSubclasser_MouseEnter()
    'Capture mouse input
    objmSubclasser.TrackMouse
End Sub

Private Sub
objmSubclasser_MouseEnterChild(ByVal hWndChild As Long)
    Debug.Print "EnterChild"
End Sub

Private Sub objmSubclasser_MouseLeaveChild(ByVal hWndChild As Long)
    Debug.Print "LeaveChild"
End Sub

Further examples:

Mouse Roll Over (Hard Way)

 

Home

Copyright and Disclaimer