MouseMove event
The MouseMove event has different arguments for different
objects:
Object |
See |
---|---|
RichTextEdit control |
|
Window |
Syntax 1 For RichTextEdit controls
Description
Occurs when the mouse has moved within the RichTextEdit control.
Event ID
Event ID |
Objects |
---|---|
pbm_renmousemove |
RichTextEdit |
Parameters
None
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Continue
processing
See Also
Syntax 2 For windows
Description
Occurs when the pointer is moved within the window.
Event ID
Event ID |
Objects |
---|---|
pbm_mousemove |
Window |
Parameters
Argument |
Description |
---|---|
flags |
UnsignedLong by Values are:
Flags is the sum of all the buttons and |
xpos |
Integer by value |
ypos |
Integer by value |
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Continue
processing
Usage
Because flags is a sum of button and
key numbers, you can find out what keys are pressed by subtracting
the largest values one by one and checking the value that remains.
For example:
-
If flags is
5, the Shift key (4) and the left mouse button (1) are pressed. -
If flags is 14, the Ctrl key
(8), the Shift key (4), and the right mouse button (2) are pressed.
This code handles all the buttons and keys (the local boolean
variables are initialized to false by default):
1 |
boolean lb_left_button, lb_right_button |
1 |
boolean lb_middle_button, lb_Shift_key, lb_control_key |
1 |
integer li_flags |
1 |
1 |
li_flags = flags |
1 |
IF li_flags 15 THEN |
1 |
   // Middle button is pressed |
1 |
   lb_middle_button = TRUE |
1 |
   li_flags = li_flags - 16 |
1 |
END IF |
1 |
1 |
IF li_flags 7 THEN |
1 |
   // Control key is pressed |
1 |
   lb_control_key = TRUE |
1 |
   li_flags = li_flags - 8 |
1 |
END IF |
1 |
1 |
IF li_flags > 3 THEN |
1 |
   // Shift key is pressed |
1 |
   lb_Shift_key = TRUE |
1 |
   li_flags = li_flags - 4 |
1 |
END IF |
1 |
1 |
IF li_flags > 1 THEN |
1 |
   // Right button is pressed |
1 |
   lb_lb_right_button = TRUE |
1 |
   li_flags = li_flags - 2 |
1 |
END IF |
1 |
1 |
IF li_flags = 1 THEN lb_left_button = TRUE |
Most controls in a window do not capture MouseMove events—the MouseMove
event is not mapped by default. If you want the window’s MouseMove
event to be triggered when the mouse moves over a control, you must
map a user-defined event to the pbm_mousemove event
for the control. The following code in the control’s user-defined
MouseMove event triggers the window’s MouseMove event:
1 |
Parent.EVENT MouseMove(0, Parent.PointerX(),<br>   Parent.PointerY()) |
Examples
This code in the MouseMove event causes a meter OLE
custom control to rise and fall continually as the mouse pointer
is moved up and down in the window workspace:
1 |
This.uf_setmonitor(ypos, ole_verticalmeter, & |
1 |
   This.WorkspaceHeight() ) |
Uf_setmonitor is a window
function that scales the pixels to the range of the gauge. It accepts
three arguments: the vertical position of the mouse pointer, an OLECustomControl
reference, and the maximum range of the mouse pointer for scaling
purposes:
1 |
double ld_gaugemax, ld_gaugemin |
1 |
double ld_gaugerange, ld_value |
1 |
1 |
// Ranges for monitor-type control |
1 |
ld_gaugemax = ocxitem.Object.MaxValue |
1 |
ld_gaugemin = ocxitem.Object.MinValue |
1 |
ld_gaugerange = ld_gaugemax - ld_gaugemin |
1 |
1 |
// Horizontal position of mouse within window |
1 |
ld_value = data * ld_gaugerange / range + ld_gaugemin |
1 |
1 |
// Set gauge |
1 |
ocxitem.Object.Value = Round(ld_value, 0) |
1 |
1 |
RETURN 1 |
The OLE custom control also has a MouseMove event.
This code in that event keeps the gauge responding when the pointer
is over the gauge. (You need to pass values for the arguments that
are usually handled by the system; the mouse position values are
specified in relation to the parent window.) For example:
1 |
Parent.EVENT MouseMove(0, Parent.PointerX(), & |
1 |
Parent.PointerY()) |