Occurs when the mouse button is moved upon the object.
Object.OnMouseMove ( enMouseButton, enKeyShift, fX, fY )
The OnMouseMove event syntax has the following parts:
Name |
Type |
Description |
Object |
An object |
A control or the AForm object |
enMouseButton |
Val enumAMouseButton |
An integer that identifies the button that was pressed (OnMouseDown) or released (OnMouseUp) to cause the event. |
enKeyShift |
Val enumAKeyShift |
An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys when the button specified in the button argument is pressed or released. |
fX, fY |
Val APixel |
Returns a number that specifies the current location of the mouse pointer. The fX and fY values are always expressed in terms of the coordinate system set by the Height, Width, Left, and Top properties of the object. |
enumAMouseButton can be one of the following:
Name |
Value |
Description |
aMouseButtonLeft |
1 |
Left button is pressed. |
aMouseButtonRight |
2 |
Right button is pressed. |
aMouseButtonMIddle |
4 |
Middle button is pressed. |
enumAKeyShift can be one of the following:
Name |
Value |
Description |
aKeyShiftNone |
0 |
No key is pressed. |
aKeyShiftShift |
1 |
SHIFT key is pressed. |
aKeyShiftCtrl |
2 |
CTRL key is pressed. |
aKeyShiftAlt |
4 |
ALT key is pressed. |
The OnMouseMove event is generated continually as the mouse pointer moves across objects. Unless another object has captured the mouse, an object recognizes an OnMouseMove event whenever the mouse position is within its borders.
If you need to test for the button or shift arguments, you can use constants listed in the table above for enumAMouseButton and enumAKeyShift.
The constants then act as bit masks you can use to test for any combination of buttons without having to figure out the unique bit field value for each combination.
You test for a condition by first assigning each result to a temporary integer variable and then comparing the button or shift arguments to a bit mask. Use the And operator with each argument to test if the condition is greater than zero, indicating the key or button is pressed, as in this example:
LeftDown = (Button And ALeftButton) > 0
CtrlDown = (Shift And ACtrlMask) > 0
Then, in a procedure, you can test for any combination of conditions, as in this example:
If LeftDown And CtrlDown Then
Note: You can use MouseDown and MouseUp event procedures to respond to events caused by pressing and releasing mouse buttons.
The button argument for OnMouseMove differs from the button argument for MouseDown and MouseUp. For OnMouseMove, the button argument indicates the current state of all buttons; a single OnMouseMove event can indicate that some, all, or no buttons are pressed. For MouseDown and MouseUp, the button argument indicates exactly one button per event.
Any time you move a window inside an OnMouseMove event, it can cause a cascading event. OnMouseMove events are generated when the window moves underneath the pointer. An OnMouseMove event can be generated even if the mouse is perfectly stationary.
chk1.OnMouseMove(nButton, nShift, x, y)
{
If nButton = aMouseButtonLeft
then ....
endif
}
|