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);