WinCheckMenuItem: Difference between revisions
Appearance
mNo edit summary |
|||
Line 1: | Line 1: | ||
This macro sets the check state of the specified menu item to the flag. | This macro sets the check state of the specified menu item to the flag. | ||
==Syntax== | ==Syntax== | ||
WinCheckMenuItem(hwndMenu, usItemId, | WinCheckMenuItem(hwndMenu, usItemId, usChkstate) | ||
==Parameters== | ==Parameters== | ||
;hwndMenu (HWND) - input | ;hwndMenu (HWND) - input:Menu window handle. | ||
:Menu window handle. | ;usId (USHORT) - input:Item identifier. | ||
;fCheck (BOOL) - input:Check flag. | |||
;usId (USHORT) - input | |||
:Item identifier. | |||
;fCheck (BOOL) - input | |||
:Check flag. | |||
==Returns== | ==Returns== | ||
; rc (BOOL) - returns | ; rc (BOOL) - returns:Success indicator. | ||
:Success indicator. | :;TRUE:Successful completion | ||
:;TRUE | :;FALSE:Error occurred. | ||
:;FALSE | |||
==Remarks== | ==Remarks== | ||
This macro expands to: | This macro expands to: | ||
#define WinCheckMenuItem(hwndMenu, usId, fCheck) | #define WinCheckMenuItem(hwndMenu, usId, fCheck) | ||
((BOOL)WinSendMsg(hwndMenu, | ((BOOL)WinSendMsg(hwndMenu, | ||
Line 30: | Line 21: | ||
MPFROM2SHORT(usId, TRUE), | MPFROM2SHORT(usId, TRUE), | ||
MPFROM2SHORT(MIA_CHECKED, (BOOL)(fCheck) ? MIA_CHECKED : 0))) | MPFROM2SHORT(MIA_CHECKED, (BOOL)(fCheck) ? MIA_CHECKED : 0))) | ||
This function requires the existence of a message queue. | This function requires the existence of a message queue. | ||
Line 55: | Line 45: | ||
/* set menu item check state */ | /* set menu item check state */ | ||
fSuccess = WinCheckMenuItem(hwndMenu, usItemId, ! usChkstate); | fSuccess = WinCheckMenuItem(hwndMenu, usItemId, ! usChkstate); | ||
</pre> | </pre> | ||
Latest revision as of 14:36, 4 October 2023
This macro sets the check state of the specified menu item to the flag.
Syntax
WinCheckMenuItem(hwndMenu, usItemId, usChkstate)
Parameters
- hwndMenu (HWND) - input
- Menu window handle.
- usId (USHORT) - input
- Item identifier.
- fCheck (BOOL) - input
- Check flag.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE
- Successful completion
- FALSE
- Error occurred.
Remarks
This macro expands to:
#define WinCheckMenuItem(hwndMenu, usId, fCheck) ((BOOL)WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(usId, TRUE), MPFROM2SHORT(MIA_CHECKED, (BOOL)(fCheck) ? MIA_CHECKED : 0)))
This function requires the existence of a message queue.
Example Code
This example responds to a select menu message (WM_MENUSELECT) by querying (via WinIsMenuItemChecked) the check attribute and then setting the check state of the menu item that was selected.
#define INCL_WINWINDOWMGR /* Window Manager Functions */ #include <os2.h> USHORT usItemId; /* menu item id */ HWND hwndMenu; /* menu handle */ BOOL usChkstate; /* new checked state */ BOOL fSuccess; /* success indicator */ MPARAM mp1; /* Parameter 1 (menu item id) */ MPARAM mp2; /* Parameter 2 (menu handle) */ case WM_MENUSELECT: usItemId = SHORT1FROMMP(mp1); hwndMenu = HWNDFROMMP(mp2); /* query current check state */ usChkstate = WinIsMenuItemChecked(hwndMenu, usItemId); /* set menu item check state */ fSuccess = WinCheckMenuItem(hwndMenu, usItemId, ! usChkstate);
Related Functions
Related Messages
- MM_SETITEMATTR