MouseMove Event
Object List Next Object
Defined By: Window
Description:
Defines the actions that occur when a user moves the mouse pointer. This event
then continues to be generated as long as the mouse pointer is moving across
objects.
Usage:
Sub MouseMove(button As Integer, shift As Integer, x As Single, y As Single)
Argument Description
button The current state of all mouse buttons, in which a bit has been set to
indicate the button or buttons are pressed, if any. The button argument sets bits that correspond to the following values: 1 for the left
button, 2 for the right button, and 4 for the middle button.
shift The status of the SHIFT, CTRL, and ALT keys when the specified button was pressed. Each of these keys has a corresponding value. SHIFT has a value
of 1, CTRL is 2, and ALT is 4. To indicate which key or keys were pressed, the
key values are added to the shift argument. For example, if only CTRL is released, the value of shift is 2.
x, y The x and y coordinates defining the current location of the mouse pointer. x and y are single-precision variables that use the coordinate system established by
the object's ScaleHeight, Scale Width, ScaleLeft, and ScaleTop properties.
Details:
You can use the arguments for this event to determine the starting location of
the mouse move, which mouse button was pressed, and if any keyboard modifiers
(SHIFT, CTRL, and ALT) were pressed.
An object detects a MouseMove event whenever the mouse pointer is within its
borders with one exception. A MouseMove event is not detected when another
object owns the mouse and mouse events. An object essentially owns a mouse event
once a mouse button is pressed over that form or control and until the MouseUp
event is processed.
To test for the button or shift arguments you can use logical operators. The virtual constants you can use to
test for various combinations of buttons are listed as follows:
Virtual Constant Value
LEFT_BUTTON 1
RIGHT_BUTTON 2
MIDDLE_BUTTON 4
SHIFT_MASK 1
CTRL_MASK 2
ALT_MAST 4
When using a MouseMove procedure, please note that the button argument indicates the current state of all buttons; whereas, the button argument for MouseDown and MouseUp indicates only one button for each event.
MouseUp/MouseDown event procedures are often used to react to events triggered
by pressing and releasing various mouse buttons.
You should be aware that a MouseMove event can cascade when:
a window is moved during a MouseMove event (for example, when the pointer
doesn't move at all, and a window moves under it)
the program is stopped abruptly before a MouseMove event is completed
See Also:
Click, DblClick events; MousePointer property; MouseDown, MouseUp events