onMouseUp (Callback)


onMouseUp (hWnd, button, x, y)

This callback is invoked when a mouse button is released.

Parameter Description
hWnd The handle to the window that triggered the event
button A constant that identifies the button that was released. See onMouseDown for a list of button constants.
x The x coordinate where the button was released. Relative to the upper left hand corner of the window
y The y coordinate where the button was released. Relative to the upper left hand corner of the window

Returns

0

Remarks

This is a callback function. You must supply this function yourself. To register this callback, call the WinXRegOnMouseUp function.

It is possible for the user to press the mouse button over your window and release it elsewhere. In this case you the onMouseDown callback will be called, but not the onMouseUp callback. To make sure you get the onMouseUp callback, capture the mouse using the SetCapture and ReleaseCapture Win32 API functions.

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 onMouseUp (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 "You released the ";button$;" mouse button at ";x;", ";y

END FUNCTION

Related Links

WinXRegOnMouseUp
onMouseDown (Callback)