Mouse and Cursor Methods

The following methods are used to position and shape the mouse cursor and to capture the mouse.

CursorPos

>>-aDialogControl~CursorPos------------------------------------><


The CursorPos method returns the current position of the mouse cursor.

Return value:

The horizontal and vertical position of the mouse, separated by a blank.

Example:

See SetCursorPos for an example on how to use this method.

SetCursorPos

>>-aDialogControl~SetCursorPos(--x--,y--)----------------------><


The SetCursorPos method moves the mouse cursor to the specified position. This method can be used to force the repainting of the mouse cursor or to keep the mouse cursor within a specific rectangle.

Arguments:

The arguments are:

x

The horizontal position of the mouse cursor, in screen pixels.

y

The vertical position of the mouse cursor, in screen pixels.

Return value:

0

Moving the mouse cursor was successful.

1

Moving the mouse cursor failed.

Example:

The following example shows two methods: one indicating that processing has started and one indicating that processing has completed. The method IndicateBeginProcessing changes the shape of the mouse cursor to the WAIT cursor and IndicateEndProcessing restores the original mouse cursor shape. Both methods retrieve the current position of the mouse cursor and move it by one screen pixel in each direction to force the repainting of the mouse cursor.

::method IndicateBeginProcessing
  self~Current_Cursor = self~Cursor_Wait
  parse value self~CursorPos with curx cury
  self~SetCursorPos(curx+1, cury+1)

::method IndicateEndProcessing
  self~RestoreCursorShape(self~Current_Cursor)
  parse value self~CursorPos with curx cury
  self~SetCursorPos(curx-1, cury-1)

See DefListDragHandler for another example on how to use the mouse methods.

RestoreCursorShape

>>-aDialogControl~RestoreCursorShape(--+--------------+--)-----><
                                       +-CursorHandle-+


The RestoreCursorShape method restores the shape of the mouse cursor.

Arguments:

The only argument is:

CursorHandle

The handle to the mouse cursor shape returned by the Cursor_Arrow, Cursor_AppStarting, Cursor_Cross, Cursor_No, or Cursor_Wait method.

If you omit this argument, the cursor shape is set to an arrow. Therefore, it is recommended that you store the original mouse cursor shape by specifying its handle when you change its shape.

Return value:

The handle to the current cursor shape, that is, the shape that was used before the cursor was restored to the given shape.

Example:

See SetCursorPos for an example on how to use this method.

Cursor_Arrow

>>-aDialogControl~Cursor_Arrow---------------------------------><


The Cursor_Arrow method sets the shape of the mouse cursor to the standard arrow. The new shape is only used when the mouse cursor is within the rectangle of the associated dialog or dialog control.

Return value:

The handle to the current cursor shape, that is, the shape that was used before the arrow shape was set.

Example:

See SetCursorPos for an example on how to use this method.

Cursor_AppStarting

>>-aDialogControl~Cursor_AppStarting---------------------------><


The Cursor_AppStarting method sets the shape of the mouse cursor to the standard arrow with a small hourglass. The new shape is only used when the mouse cursor is within the rectangle of the associated dialog or dialog control.

Return value:

The handle to the current cursor shape, that is, the shape that was used before the arrow shape with the hourglass was set.

Example:

See SetCursorPos for an example on how to use this method.

Cursor_Cross

>>-aDialogControl~Cursor_Cross---------------------------------><


The Cursor_Cross method sets the shape of the mouse cursor to a crosshair. The new shape is only used when the mouse cursor is within the rectangle of the associated dialog or dialog control.

Return value:

The handle to the current shape, that is, the shape that was used before the crosshair cursor shape was set.

Example:

See SetCursorPos for an example on how to use this method.

Cursor_No

>>-aDialogControl~Cursor_No------------------------------------><


The Cursor_No method sets the shape of the mouse cursor to a slashed circle to deny access. The new shape is only used when the mouse cursor is within the rectangle of the associated dialog or dialog control.

Return value:

The handle to the current shape, that is, the shape that was used before the slashed-circle cursor shape was set.

Example:

See SetCursorPos for an example on how to use this method.

Cursor_Wait

>>-aDialogControl~Cursor_Wait----------------------------------><


The Cursor_Wait method sets the shape of the mouse cursor to the hourglass. The new shape is only used when the mouse cursor is within the rectangle of the associated dialog or dialog control.

Return value:

The handle to the current shape, that is, the shape that was used before the hourglass shape was set.

Example:

See SetCursorPos for an example on how to use this method.

GetMouseCapture

>>-aDialogControl~GetMouseCapture------------------------------><


The GetMouseCapture method retrieves the dialog or dialog control that captured the mouse. This dialog or dialog control receives the entire mouse input regardless of whether the mouse cursor is within the borders of the dialog or dialog control.

Return value:

The handle to the dialog or dialog control that captures the mouse, or 0 if the mouse is not captured.

CaptureMouse

>>-aDialogControl~CaptureMouse---------------------------------><


The CaptureMouse method captures the mouse. This means that the associated dialog or dialog control receives the entire mouse input regardless of whether the mouse cursor is within the borders of the dialog or dialog control.

Return value:

The handle to the dialog or dialog control that previously captured the mouse, or 0 if the mouse was not captured before.

Note: If you change the cursor shape while the mouse is being captured, this change is ignored.

ReleaseMouseCapture

>>-aDialogControl~ReleaseMouseCapture--------------------------><


The ReleaseMouseCapture method releases the mouse capture from a dialog or dialog control and restores normal mouse input processing. This means that the mouse input is then received by another dialog or dialog control that captured the mouse.

Return value:

0

The mouse capture was released.

1

Releasing the mouse capture failed.

IsMouseButtonDown

>>-aDialogControl~IsMouseButtonDown(--"--+-LEFT---+--"--)------><
                                         +-MIDDLE-+
                                         +-RIGHT--+


The IsMouseButtonDown method retrieves information on whether a mouse button is pressed.

Arguments:

The only argument is:

button

The location of the mouse button you are interested in.

Return value:

0

The button is not being pressed.

1

The button is being pressed.