MouseMove Event
Occurs when the user moves the mouse over an object.
PROCEDURE Object.MouseMove
LPARAMETERS [nIndex,] nButton, nShift, nXCoord, nYCoord
Parameters
You must include an LPARAMETERS or PARAMETERS statement in the event procedure and specify a name for each parameter. Visual FoxPro passes the MouseMove event four or five parameters in the following order:
nIndex
Contains a number, which uniquely identifies a control if it is in a control array. The nIndex parameter is passed only when the control is in a control array.nButton
Contains a number that specifies which mouse button was being held down as the mouse was moved, as listed in the following table:Mouse button values for nButton
Windows nButton Value Left mouse button 1 Right mouse button 2 Middle mouse button 4 If more than one mouse button is held down as the mouse is moved, nButton contains the sum of the values for the mouse buttons. For example, if both the left and right mouse buttons are pressed, the value of nButton is 3.
nShift
Contains a number specifying the state of modifier keys when the mouse is moved. In Visual FoxPro for Windows, the valid modifier keys are the SHIFT, CTRL, and ALT keys.The values returned in nShift for individual modifier keys are listed in the following table.
Modifier key values for nShift
Windows key Value SHIFT 1 CTRL 2 ALT 4 If more than one modifier key is held down when the mouse is pressed, the nShift argument contains the sum of the values for the modifier keys. For example, in Visual FoxPro for Windows, if the user holds CTRL while pressing the mouse button, the nShift argument contains 2. But if the user holds CTRL+ALT while pressing the mouse button, the nShift argument contains 6.
nXCoord, nYCoord
Contains the current horizontal (nXCoord) and vertical (nYCoord) position of the mouse pointer within the form. These coordinates are always expressed in terms of the form's coordinate system, in the unit of measurement specified in the ScaleMode property setting.
The MouseMove event is triggered continually as the mouse pointer moves across objects.
Note You can use MouseDown and MouseUp events to respond to events caused by pressing and releasing mouse buttons. The nButton parameter for MouseMove differs from the nButton parameter for MouseDown and MouseUp. For MouseMove, the nButton parameter indicates the current state of all buttons; a single MouseMove event can indicate that some, all, or no buttons are pressed. For MouseDown or MouseUp, the nButton parameter indicates exactly one button per event. Avoid moving a window inside a MouseMove event procedure; it can cause cascading events and generate run-time errors, such as a stack overflow. MouseMove events are triggered when the window moves underneath the pointer. A MouseMove event can be triggered even if the mouse is stationary.
See Also
Click Event | DblClick Event | MiddleClick Event | MousePointer Property | MouseDown Event | MouseUp Event | MouseWheel Event
Applies To: CheckBox | Column | ComboBox | CommandButton | CommandGroup | Container Object | Control Object | EditBox | Form | Grid | Header | Image | Label | Line | ListBox | OptionButton | OptionGroup | Page | PageFrame | Shape | Spinner | TextBox | ToolBar