WinCheckMenuItem
Appearance
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);
Definition
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwndMenu; /* Menu window handle. */ USHORT usId; /* Item identifier. */ BOOL fCheck; /* Check flag. */ BOOL rc; /* Success indicator. */ rc = WinCheckMenuItem(hwndMenu, usId, fCheck);
Related Functions
- WinSendMsg
Related Messages
- MM_SETITEMATTR