WinShowCursor: Difference between revisions
Appearance
mNo edit summary |
|||
Line 1: | Line 1: | ||
This function shows or hides the cursor that is associated with a specified window. | This function shows or hides the cursor that is associated with a specified window. | ||
==Syntax== | ==Syntax== | ||
WinShowCursor(hwnd, fShow) | WinShowCursor(hwnd, fShow) | ||
==Parameters== | ==Parameters== | ||
;hwnd (HWND) - input | ;hwnd (HWND) - input:Handle of window to which the cursor belongs. | ||
:Handle of window to which the cursor belongs. | ;fShow (BOOL) - input:Show indicator. | ||
::TRUE: Make cursor visible | |||
::FALSE: Make cursor invisible. | |||
==Returns== | ==Returns== | ||
;rc (BOOL) - returns | ;rc (BOOL) - returns:Success indicator. | ||
:Success indicator. | ::TRUE: Successful completion | ||
: | ::FALSE: Error occurred, or an attempt was made to show the cursor when it was already visible. | ||
: | |||
==Errors== | ==Errors== | ||
Possible returns from WinGetLastError | Possible returns from WinGetLastError | ||
;PMERR_INVALID_HWND (0x1001) | ;PMERR_INVALID_HWND (0x1001):An invalid window handle was specified. | ||
:An invalid window handle was specified. | |||
==Remarks== | ==Remarks== | ||
This function must be called by the same thread that created the cursor that is affected. | This function must be called by the same thread that created the cursor that is affected. | ||
A cursor show-level count is maintained. It is incremented by a hide operation and decremented by a show operation. The cursor is actually visible if the cursor show-level count is zero, otherwise it is invisible. When decrementing, the cursor show-level count is fixed at zero so as not to show the cursor too many times, but it is possible to hide the cursor a number of times in succession. | A cursor show-level count is maintained. It is incremented by a hide operation and decremented by a show operation. The cursor is actually visible if the cursor show-level count is zero, otherwise it is invisible. When decrementing, the cursor show-level count is fixed at zero so as not to show the cursor too many times, but it is possible to hide the cursor a number of times in succession. | ||
==Example Code== | ==Example Code== | ||
This example shows the cursor if it is successfully created. | This example shows the cursor if it is successfully created. | ||
<pre> | <pre> | ||
#define INCL_WINCURSORS | #define INCL_WINCURSORS | ||
#include < | #include <os2.h> | ||
HWND hwnd; /* handle of window that has pointer captured */ | HWND hwnd; /* handle of window that has pointer captured */ | ||
Line 51: | Line 48: | ||
WinShowCursor(hwnd, | WinShowCursor(hwnd, | ||
TRUE); /* make cursor visible. */ | TRUE); /* make cursor visible. */ | ||
</pre> | </pre> | ||
Latest revision as of 20:44, 12 April 2024
This function shows or hides the cursor that is associated with a specified window.
Syntax
WinShowCursor(hwnd, fShow)
Parameters
- hwnd (HWND) - input
- Handle of window to which the cursor belongs.
- fShow (BOOL) - input
- Show indicator.
- TRUE: Make cursor visible
- FALSE: Make cursor invisible.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE: Successful completion
- FALSE: Error occurred, or an attempt was made to show the cursor when it was already visible.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Remarks
This function must be called by the same thread that created the cursor that is affected.
A cursor show-level count is maintained. It is incremented by a hide operation and decremented by a show operation. The cursor is actually visible if the cursor show-level count is zero, otherwise it is invisible. When decrementing, the cursor show-level count is fixed at zero so as not to show the cursor too many times, but it is possible to hide the cursor a number of times in succession.
Example Code
This example shows the cursor if it is successfully created.
#define INCL_WINCURSORS #include <os2.h> HWND hwnd; /* handle of window that has pointer captured */ RECTL rcl; WinQueryWindowRect(hwnd, &rcl); if (WinCreateCursor(hwnd, /* This must be the handle */ /* of a window for which */ /* the application can */ /* receive input. */ 100, /* x,y position of cursor. */ 100, 5, /* cursor width. */ 5, /* cursor height. */ CURSOR_FLASH, &rcl)) /* region where the cursor */ /* is visible. */ WinShowCursor(hwnd, TRUE); /* make cursor visible. */