onMouseDown (Callback)


onMouseDown (hWnd, button, x, y)

This callback is invoked when a mouse button is pressed.

Parameter Description
hWnd The handle to the window that triggered the event
button A constant identifying the button that was pushed, see remarks for more information
x The x coordinate where the button was pushed. Relative to the upper left hand corner of the window
y The y coordinate where the button was pushed. Relative to the upper left hand corner of the window

Returns

0

Remarks

This is a callback function. You must supply this function yourself. Regsiter this function with the WinXRegOnMouseDown function.

The button parameter will be one of the following constants:

$$MBT_LEFT
The left mosue button
$$MBT_MIDDLE
The middle mouse button (or the wheel for wheel mice)
$$MBT_RIGHT
The right mouse button

In general, if an action occurs when the user clicks something, you should cause that action to occur when the onMouseUp callback is invoked, not the onMouseDown callback. This gives the user a chance to cancel the action by moving the mouse away from your window and releasing it there.

Examples

FUNCTION onMouseDown (hWnd, button, x, y)

'find our which button was pressed
SELECT CASE button

CASE $$MBT_LEFT: button$ = "left"
CASE $$MBT_MIDDLE: button$ = "middle"
CASE $$MBT_RIGHT: button$ = "right"

END SELECT

'assuming we have a console attached to this app,
'print the button and where it was clicked
PRINT "The " ;button$;" mouse button was pressed at ";x", ";y

END FUNCTION

Related Links

WinXRegOnMouseDown
onMouseUp (Callback)