Table of contents
TOC
Collapse the table of content
Expand the table of content

MouseMove Event

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Occurs when the user moves the mouse. Syntax For MultiPage, TabStrip Private SubobjectMouseMove(_indexAs Long, ByValButtonAs fmButton, ByValShiftAs fmShiftState, ByValXAs Single, ByValYAs Single) For other controls Private SubobjectMouseMove( ByVal_ButtonAs fmButton, ByValShiftAs fmShiftState, ByValXAs Single, ByValYAs Single) The MouseMove event syntax has these parts:

PartDescription
objectRequired. A valid object name.
indexRequired. The index of the page or tab in a MultiPage or TabStrip associated with this event.
ButtonRequired. An integer value that identifies the state of the mouse buttons.
ShiftRequired. Specifies the state of SHIFT, CTRL, and ALT.
X, YRequired. The horizontal or vertical position, measured in points, from the left or top edge of the control.

Settings The index argument specifies which page or tab was clicked over. A - 1 designates that the user did not click on any of the pages or tabs. The settings for Button are:

ValueDescription
0No button is pressed.
1The left button is pressed.
2The right button is pressed.
3The right and left buttons are pressed.
4The middle button is pressed.
5The middle and left buttons are pressed.
6The middle and right buttons are pressed.
7All three buttons are pressed.

The settings for Shift are:

ValueDescription
1SHIFT was pressed.
2CTRL was pressed.
3SHIFT and CTRL were pressed.
4ALT was pressed.
5ALT and SHIFT were pressed.
6ALT and CTRL were pressed.
7ALT, SHIFT, and CTRL were pressed.

You can identify individual keyboard modifiers by using the following constants:

ConstantValueDescription
fmShiftMask1Mask to detect SHIFT.
fmCtrlMask2Mask to detect CTRL.
fmAltMask4Mask to detect ALT.

Remarks The MouseMove event applies to forms, controls on a form, and labels. MouseMove events are generated continually as the mouse pointer moves across objects. Unless another object has captured the mouse, an object recognizes a MouseMove event whenever the mouse position is within its borders. Moving a form can also generate a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can continually generate (cascade) MouseMove events. If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event might not occur for that space. In such cases, you might need to respond to the MouseMove event in both controls. You can use the value returned in the Button argument to identify the state of the mouse buttons. Use the Shift argument to identify the state of SHIFT, CTRL, and ALT when the MouseMove event occurred. For example, if both CTRL and ALT are pressed, the value of Shift is 6.

Note You can use MouseDown and MouseUp event procedures to respond to events caused by pressing and releasing mouse buttons.

© 2018 Microsoft