Show and Hide the Menu bar dynamically
-
Hi All, I' m writing a Visual C++ MFC dialog-based program. I added a Menu bar uisng Insert->Resource-> Menu, not by writing code. Then, I tried to show and hide the Menu bar of a modal dialog dynamically but didn't succeed? Could anyone kindly help me? Cheers, hmc
-
Hi All, I' m writing a Visual C++ MFC dialog-based program. I added a Menu bar uisng Insert->Resource-> Menu, not by writing code. Then, I tried to show and hide the Menu bar of a modal dialog dynamically but didn't succeed? Could anyone kindly help me? Cheers, hmc
I don't know any direct command that show/hide menu but the following will work too. For removing menu bar at run time use following code CWnd* pMain = AfxGetMainWnd(); if (pMain != NULL) { CMenu* pMenu = pMain->GetMenu(); while(pMenu != NULL && pMenu->GetMenuItemCount() > 0) { pMenu->DeleteMenu(0, MF_BYPOSITION); pMain->DrawMenuBar(); } } For adding menu items again, use AppendMenu
-
I don't know any direct command that show/hide menu but the following will work too. For removing menu bar at run time use following code CWnd* pMain = AfxGetMainWnd(); if (pMain != NULL) { CMenu* pMenu = pMain->GetMenu(); while(pMenu != NULL && pMenu->GetMenuItemCount() > 0) { pMenu->DeleteMenu(0, MF_BYPOSITION); pMain->DrawMenuBar(); } } For adding menu items again, use AppendMenu