ClickControl Event

Applies to:  PowerForm Control
See also:  ClickChild Event, Event Index

The ClickControl event occurs when the subclassed window has captured mouse input, and a mouse button is clicked whilst the mouse pointer is within a control placed in the same container as the PowerForm control.

Syntax:

Private Sub object_ClickControl(ctl As Object, ByVal Button As MouseButtonConstants, ByVal Shift As Boolean, ByVal Control As Boolean, ByVal x As Long, ByVal y As Long)

The ClickControl event syntax has these parts:

Part Description
object The name of a PowerForm control.
ctl A reference to the control that was clicked.
Button A value indicating which button was clicked.  Can be any one of the following values:
  • vbLeftButton
  • vbMiddleButton
  • vbRightButton
Shift A boolean value indicating the state of the Shift key.  A value of True indicates that one or both Shift keys are down.
Control A boolean value indicating the state of the Control key.  A value of True indicates that one or both Control keys are down
x The x coordinate (in pixels) of the mouse pointer at the time it was clicked, relative to the top-left corner of the window or control.
y The y coordinate (in pixels) of the mouse pointer at the time it was clicked, relative to the top-left corner of the window or control.

Remarks:

The ClickControl event is only raised if the control was added to the form at design time.  Clicking on dynamically loaded controls will not generate a ClickControl event.  The ClickChild event of the Subclasser object would be better suited to that task.

The ClickControl event is only raised if the subclassed window has captured mouse input.  To enable the ClickControl 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:

'This example disables normal handling of mouse events
'by controls on the form, and outputs a message whenever
'the user clicks on a control on the form.

Option Explicit


Private Sub PowerForm1_ClickControl(ctl As Object, ByVal Button As MouseButtonConstants, ByVal Shift As Boolean, ByVal Control As Boolean, ByVal x As Long, ByVal y As Long)
    Debug.Print "ClickControl " & ctl.Name
End Sub

Private Sub
PowerForm1_MouseEnter()
   
'Call TrackMouse to enable the ClickControl event.
    PowerForm1.TrackMouse
End Sub

Private Sub PowerForm1_MouseLeave(ByVal Side As AkemiPowerPack.SideConstants, Cancel As Boolean)
    If Side = siChildWindow Then
        'Cancel the MouseLeave event if the mouse pointer
        'has entered a child window.  This will have the
        'effect of retaining mouse capture until the
        'mouse pointer leaves the SubClassed window
        'all together.

        Cancel = True
    End If
End Sub

 

Home

Copyright and Disclaimer