//MainFrm.h
// ... ...
bool isEnable; // if the submenu is enable
bool isChecked; // if the submenu is checked
// ... ...
// define On_Update_Menu handler
afx_msg void OnUpdateMenu(CCmdUI* pCmdUI);
// ... ...
//MainFrm.cpp
// ... ...
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
// ... ...
ON_UPDATE_COMMAND_UI(ID_SUBMENU1/*Submenu's command ID*/, OnUpdateMenu)
END_MESSAGE_MAP()
// ... ...
void CMainFrame::OnUpdateMenu(CCmdUI* pCmdUI)
{
// set the state of the submenu.
// You can resign the value of isChecked and isEnable in other handler to control the state of this submenu.
if(pCmdUI->m_nID == ID_SUBMENU1)
{
pCmdUI->SetCheck(isChecked);
pCmdUI->Enable(isEnable);
}
}