Dialog app - menu
-
I have a dialog app. i work with a menu: CMenu * menu = this->GetMenu(); menu->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED); and so,so. - and i have a boolean variable that i modify on each click. Then i have to hide the menu. SetMenu(NULL). Then when i load it again,now it executes all the commands, but it does not check or uncheck any items... what could i do ? Thanks.
-
I have a dialog app. i work with a menu: CMenu * menu = this->GetMenu(); menu->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED); and so,so. - and i have a boolean variable that i modify on each click. Then i have to hide the menu. SetMenu(NULL). Then when i load it again,now it executes all the commands, but it does not check or uncheck any items... what could i do ? Thanks.
This is a working example:
CMenu m_menu; // declared in CYourDlg header file
//
// Load the menu and assign to the dialog
BOOL CYourDlg::OnInitDialog()
{
...
m_menu.LoadMenu(IDR_MENU1);
SetMenu(&m_menu);
...
}
// on menu command (ID_XXX) message-handler function
void CYourDlg::OnMenuXXXCommand()
{
CMenu * menu = GetMenu();
if(menu)
{
// check/uncheck the menu item
CMenu* pPopup = menu->GetSubMenu(0);
if(pPopup->GetMenuState(ID_XXX,MF_BYCOMMAND)&MF_CHECKED)
pPopup->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_UNCHECKED);
else
pPopup->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED);
// do something
}
// on some button click message-handler function
void CYourDlg::OnButtonClick()
{
// show/hide the menu
if(GetMenu())
SetMenu(NULL);
else
SetMenu(&m_menu);
}Regards, Andrzej Markowski
My Latest ArticlesCCustomBitmapButton: An owner-draw button and a frame for the caption bar, in one class. CCustomTabCtrl: A clone of the Excel tab sheet control.