MouseEnterControl Event

Applies to:  PowerForm Control
See also:  MouseLeaveControl event, MouseEnterChild event, TrackMouse method, ReleaseMouse method, Event Index

The MouseEnterControl event occurs when the subclassed window has captured mouse input, and the mouse pointer moves over a control placed in the same container as the PowerForm control.

Syntax:

Private Sub object_MouseDownControl(ctl As Object)

The MouseEnterControl event syntax has these parts:

Part Description
object The name of a PowerForm control.
ctl A reference to the control over which the mouse pointer has moved.

Remarks:

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

The MouseEnterControl event is only raised if the subclassed window has captured mouse input.  

To enable the MouseEnterControl event, call TrackMouse in the MouseEnter event.  

By default, the PowerForm control will release mouse capture when the mouse pointer leaves the subclassed window or enters a child control.

In order to retain mouse input capture when the mouse pointer enters a child window, cancel any MouseLeave events where Side = siChildWindow.  This will disable normal processing of mouse messages by child windows, and will allow the PowerForm control to handle messages that would normally be processed by child windows.

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