Applies to: Subclasser object
See also: MouseDownControl event,
MouseUpChild event, ClickChild
event, MouseEnterChild event, MouseLeaveChild
event, MouseEnter event, MouseLeave
event, TrackMouse method, ReleaseMouse
method, Event Index
The MouseDownChild event occurs when the subclassed window has captured mouse
input, and a mouse button is pressed whilst the mouse pointer is within a child
window of the subclassed window.
Syntax:
Private Sub object_MouseDownChild(ByVal
hWndChild
As Long, ByVal
Button
As MouseButtonConstants, ByVal
Shift
As Boolean, ByVal
Control
As Boolean, ByVal x As
Long, ByVal y As
Long, Cancel As Boolean)
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 in which the mouse button was pressed.
|
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. |
Cancel |
A boolean value indicating whether to cancel normal processing of the
MouseDown event. Setting Cancel = True in response to a
MouseDownChild 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 MouseDownChild event is only raised if the subclassed window has captured
mouse input. To enable the MouseDownChild event, call TrackMouse in the
MouseEnter
event.
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 Subclasser object 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 WithEvents objmSubclasser As
Subclasser
Private Sub Form_Load()
'Subclass this form
Set objmSubclasser =
SubClassWindow(hWnd)
End Sub
Private Sub objmSubclasser_MouseEnter()
'Capture mouse input to
enable the ClickChild event.
objmSubclasser.TrackMouse
End Sub
Private Sub objmSubclasser_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
Private Sub objmSubclasser_MouseDownChild(ByVal hWndChild
As Long, ByVal Button
As MouseButtonConstants, ByVal Shift
As Boolean, ByVal Control
As Boolean, ByVal x
As Long, ByVal y
As Long, Cancel As
Boolean)
Debug.Print
"MouseDownChild"
End Sub
|
|