MouseDown Event

Applies to:  MouseEvents
See also:  Window object

Occurs when a window is about to receive a MouseDown event.

Syntax:

Public Event MouseDown(ByRef Window As Window, ByVal Button As MouseButtonConstants, ByVal Shift As Boolean, ByVal Control As Boolean, ByVal x As Long, ByVal y As Long, Byref Cancel As Boolean)

The MouseDown event syntax has these parts:

Part Description
object The name of a MouseEvents object.  NB:  object must be declared using WithEvents.
Window The window in which the mouse button was pressed.
Button A value indicating which button was pressed.  Can be one of vbLeftButton, vbMiddleButton, vbRightButton.
Shift A boolean value indicating the state of the shift button.  A vale of True indicates that the shift key is down.
Control A boolean value indicating the state of the ctrl button.  A vale of True indicates that the ctrl key is down.
x The x coordinate of the mouse pointer, in client coordinates (pixels).  May be negative, if the mouse is over the border or caption of a top-level or mdi child window.
y The y coordinate of the mouse pointer, in client coordinates (pixels).  May be negative, if the mouse is over the border or caption of a top-level or mdi child window.
Cancel A boolean value that determines whether Window will receive the MouseDown event.  Setting Cancel to True prevents the event from being passed on.

Remarks:

Note that a Click event is the result of a MouseDown event followed by a MouseUp event within the same window.  Cancelling the MouseDown event will cancel the Click event.

Example:

Trapping mouse events

 

Home Copyright and Disclaimer