CMenu menu; menu.LoadMenu(IDR_MENU1); // Check the first item in the File menu CMenu* fileMenu = menu.GetSubMenu(0); fileMenu->CheckMenuItem(ID_FILE_OPEN, MF_BYCOMMAND | MF_CHECKED);
CMenu menu; menu.LoadMenu(IDR_MENU2); // Uncheck all items in the Edit menu CMenu* editMenu = menu.GetSubMenu(1); for (int i = 0; i < editMenu->GetMenuItemCount(); i++) { editMenu->CheckMenuItem(i, MF_BYPOSITION | MF_UNCHECKED); }This code loads another menu resource (IDR_MENU2) and unchecks all items in the Edit menu. The CMenu CheckMenuItem function is part of the MFC library, which is a package library that provides a framework for developing Windows-based applications using C++.