SetCursor

  HCURSOR SetCursor(hcur)    
  HCURSOR hcur; /* handle of cursor */

The SetCursor function sets the cursor.

Parameters

hcur

Identifies the cursor resource. The resource must have been loaded previously by using the LoadCursor function. If this parameter is NULL, the cursor is removed from the screen.

Return Value

The return value is the handle of the previous cursor, or NULL if there is no previous cursor.

Comments

The cursor is set only if the new cursor is different from the previous cursor; otherwise, the function returns immediately. The function is quite fast if the new cursor is the same as the old.

The cursor is a shared resource. A window should set the cursor only when the cursor is in the window's client area or when the window is capturing all mouse input. In systems without a mouse, the window should restore the previous cursor before the cursor leaves the client area or before the window relinquishes control to another window.

An application that needs to set the cursor while it is in a window must make sure the class cursor for the given window's class is set to NULL. If the class cursor is not NULL, the system restores the previous shape each time the mouse is moved.

The cursor is not shown on the screen if the cursor display count is less than zero. This results from the HideCursor function being called more times than the ShowCursor function.

See Also

LoadCursor, ShowCursor, SetCursorPos