WinSetKeyboardStateTable: Difference between revisions
Appearance
Created page with "This function gets or sets the keyboard state. ==Syntax== WinSetKeyboardStateTable(hwndDeskTop, abKeyStateTable, fSet) ==Parameters== ;hwndDeskTop (HWND) - Input : Desktop-window handle. :;HWND_DESKTOP ::The desktop-window handle :;Other ::Specified desktop-window handle. ;abKeyStateTable (PBYTE) - In/Out : Key state table. : This is a 256-byte table indexed by virtual key value. : For any virtual key, the 0x80 bit is set if the key is down, and zero if it is..." |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
==Syntax== | ==Syntax== | ||
WinSetKeyboardStateTable(hwndDeskTop, abKeyStateTable, fSet) | |||
==Parameters== | ==Parameters== | ||
Line 18: | Line 18: | ||
: Set indicator. | : Set indicator. | ||
:;TRUE | :;TRUE | ||
::The keyboard state is set from | ::The keyboard state is set from abKeyStateTable | ||
:;FALSE | :;FALSE | ||
::The keyboard state is copied to | ::The keyboard state is copied to abKeyStateTable. | ||
==Returns== | ==Returns== | ||
Line 38: | Line 38: | ||
==Example Code== | ==Example Code== | ||
<PRE> | |||
#define INCL_WININPUT /* Or use INCL_WIN, INCL_PM, */ | |||
#include <os2.h> | |||
HWND hwndDeskTop; /* Desktop-window handle. */ | |||
PBYTE abKeyStateTable; /* Key state table. */ | |||
BOOL fSet; /* Set indicator. */ | |||
BOOL rc; /* Success indicator. */ | |||
rc = WinSetKeyboardStateTable(hwndDeskTop, | |||
abKeyStateTable, fSet); | |||
</PRE> | |||
This example turns on Caps Lock. | |||
<PRE> | <PRE> | ||
#define INCL_WININPUT | #define INCL_WININPUT |
Latest revision as of 16:47, 9 April 2025
This function gets or sets the keyboard state.
Syntax
WinSetKeyboardStateTable(hwndDeskTop, abKeyStateTable, fSet)
Parameters
- hwndDeskTop (HWND) - Input
- Desktop-window handle.
- HWND_DESKTOP
- The desktop-window handle
- Other
- Specified desktop-window handle.
- abKeyStateTable (PBYTE) - In/Out
- Key state table.
- This is a 256-byte table indexed by virtual key value.
- For any virtual key, the 0x80 bit is set if the key is down, and zero if it is up. The 0x01 bit is set if the key is toggled, (pressed an odd number of times), otherwise it is zero.
- fSet (BOOL) - Input
- Set indicator.
- TRUE
- The keyboard state is set from abKeyStateTable
- FALSE
- The keyboard state is copied to abKeyStateTable.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE
- Successful completion
- FALSE
- Error occurred.
Remarks
This function does not change the physical state of the keyboard, but changes the value returned by WinGetKeyState, not WinGetPhysKeyState. To set the state of a single key, first get the entire table, modify the individual key, and then set the table from the modified value.
Errors
Possible returns from WinGetLastError:
- PMERR_INVALID_HWND (0x1001) An invalid window handle was specified.
Example Code
#define INCL_WININPUT /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwndDeskTop; /* Desktop-window handle. */ PBYTE abKeyStateTable; /* Key state table. */ BOOL fSet; /* Set indicator. */ BOOL rc; /* Success indicator. */ rc = WinSetKeyboardStateTable(hwndDeskTop, abKeyStateTable, fSet);
This example turns on Caps Lock.
#define INCL_WININPUT #include <OS2.H> BYTE KeyState[256]; /* This is a 256 byte table */ /* indexed by virtual key */ /* value. */ /* For any virtual key, the */ /* 0x80 bit is set if the key */ /* is down, and zero if it is */ /* up. The 0x01 bit is set */ /* if the key is toggled, */ /* (pressed an odd number */ /* of times), otherwise it is */ /* zero. */ WinSetKeyboardStateTable(HWND_DESKTOP, KeyState, FALSE); /* get a copy of the keyboard */ /* state. */ KeyState[VK_CAPSLOCK] |= 0x01; /* set the CAPSLOCK key to */ /* on state */ WinSetKeyboardStateTable(HWND_DESKTOP, KeyState, TRUE); /* set the keyboard state */