There are times when we want to indicate if a menu item has been selected or not. One way of doing this is to put a check mark on the menu item when it is selected and removing the check mark when it is not selected. It is best to maintain a boolean variable in the class that indicates the state. Here I will use _checkOn. Next it is important to locate the owner of a menu. If you have created your own window with a menu, then the current window is the owner of the menu. When you use appExpert to create an SDI project, the main menu is a member of the SDIDecFrame. If you want to access the menu from the main window, you must remember that it belongs to the Parent of that window.
Once you know the owner of the menu, determine the menu number. To do start with the first menu on the menu bar. It is number 0. Add one for each menu until you get to the menu with the item to have a check mark. Do not count separators. Call this number menuNumber. Next find out which item in the menu has the check. Once again start with zero and count to the item with the check. Do not count separators. Let the variable itemNumber represent this number. Also let CM_MENU_COMMAND be the number associated with this menu entry.
The following code will set or delete the check if the current window owns the menu.
_checkOn = !_checkOn;
TMenu menu(HWindow);
HMENU hMenu = menu.GetSubMenu(menuNumber);
TMenuItemEnabler(hMenu,CM_MENU_COMMAND,HWindow,itemNumber).SetCheck(_checkOn);
The code should be inserted in the command handler for this menu item. In the case that the main window is checking an item in the main menu, all occurences of HWindow must be replaced with Parent->HWindow.