MouseMove Event

Purpose

Occurs when the user moves the mouse.

Syntax

Sub Object_MouseMove([index%,] button&, shift&, x!, y!)

Object:Ocx Object
button&, shift&:Short integer exp
x!, y!:Single exp

Description

Object - Returns an Ocx object expression.

index% - Returns an integer that uniquely identifies a form or control if it's in a form or control array.

button - Returns an integer that identifies the button that was pressed (MouseDown) or released (MouseUp) to cause the event. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.

shift - Returns 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. A bit is set if the key is down. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2). These bits correspond to the values 1, 2, and 4, respectively. The shift argument indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT were pressed, the value of shift would be 6.

x, y - Returns a number that specifies the current location of the mouse pointer. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.

The MouseMove event is 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.

Ocx controls that are aligned at the border of the parent form (using Align) change the Scale settings of the parent. ScaleLeft and ScaleTop are set to the top-left pixel of the uncovered client area of the form. ScaleWidth and ScaleHeight are set to width and height of the uncovered area. The mouse coordinates returned from MouseX, MouseY and that are passed in the forms MouseMove, MouseUp, and MouseDown events are relative to the new origin.

Example

OpenW # 1 : FontName = "courier new"

// This next line replaces the mouse position co-ordinates ...

// ...printed in the default font when win_1 was opened and before...

// ...the fontname setting was enacted.

Win_1_MouseMove(0, 0, MouseX, MouseY)

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_MouseMove(Button&, Shift&, x!, y!)

Print AT(1, 1); "Mouse Position: "; x!; " : "; y!; Space(10)

EndSub

Remarks

See Also

Form, Click, DblClick, MouseDown

{Created by Sjouke Hamstra; Last updated: 19/10/2014 by James Gaite}