Menu
-
How to delete menu from my application and create and insert another menu. I would like to have two menu resources ( For example IDR_MENU1, IDR_MENU2), and I want to "step" between them dinamically, without exiting the programm. Actually i've already posted similar question about "multilanguage problems", and the menu is the last problem i have:).
-
How to delete menu from my application and create and insert another menu. I would like to have two menu resources ( For example IDR_MENU1, IDR_MENU2), and I want to "step" between them dinamically, without exiting the programm. Actually i've already posted similar question about "multilanguage problems", and the menu is the last problem i have:).
-
How to delete menu from my application and create and insert another menu. I would like to have two menu resources ( For example IDR_MENU1, IDR_MENU2), and I want to "step" between them dinamically, without exiting the programm. Actually i've already posted similar question about "multilanguage problems", and the menu is the last problem i have:).
CMainFrame header
CMenu m_menu;
HMENU SetNewMenu(UINT nMenu);
CMainFrame body
HMENU CMainFrame::SetNewMenu(UINT nMenu)
{
// Load the menu from the resources
m_menu.LoadMenu(nMenu);
m_menu.LoadToolbar(nMenu); // if you will need a toolbar alsoreturn (m\_menu.Detach());
}
Code that sets menu
CMenu* pMenu = AfxGetMainWnd()->GetMenu();
if (pMenu)
pMenu->DestroyMenu();CMainFrame* pFrame = reinterpret_cast<CMainFrame*>(m_pMainWnd)->SetNewMenu(IDR_MENU1);
ASSERT(pFrame != NULL);HMENU hMenu = pFrame->NewMenu();
CMenu* pNewMenu = CMenu::FromHandle( hMenu );
ASSERT(pNewMenu != NULL);AfxGetMainWnd()->SetMenu(pNewMenu);
Ant.
-
CMainFrame header
CMenu m_menu;
HMENU SetNewMenu(UINT nMenu);
CMainFrame body
HMENU CMainFrame::SetNewMenu(UINT nMenu)
{
// Load the menu from the resources
m_menu.LoadMenu(nMenu);
m_menu.LoadToolbar(nMenu); // if you will need a toolbar alsoreturn (m\_menu.Detach());
}
Code that sets menu
CMenu* pMenu = AfxGetMainWnd()->GetMenu();
if (pMenu)
pMenu->DestroyMenu();CMainFrame* pFrame = reinterpret_cast<CMainFrame*>(m_pMainWnd)->SetNewMenu(IDR_MENU1);
ASSERT(pFrame != NULL);HMENU hMenu = pFrame->NewMenu();
CMenu* pNewMenu = CMenu::FromHandle( hMenu );
ASSERT(pNewMenu != NULL);AfxGetMainWnd()->SetMenu(pNewMenu);
Ant.
Thanks, that helped me so much. Actually i used it in Pocket PC, but using the different way. I used there CCeCommandBar, and just did this:
AfxSetResourceHandle(hInst); CMainFrame\* pMainFrame = (CMainFrame\*)AfxGetApp()->m\_pMainWnd; pMainFrame->m\_wndMenuBar.ResetCommandBar(); pMainFrame->m\_wndMenuBar.InsertMenuBar(IDR\_MAINFRAME); pMainFrame->m\_wndMenuBar.LoadToolBar(IDR\_TOOLBAR1);
Thanks again.
-
Thanks, that helped me so much. Actually i used it in Pocket PC, but using the different way. I used there CCeCommandBar, and just did this:
AfxSetResourceHandle(hInst); CMainFrame\* pMainFrame = (CMainFrame\*)AfxGetApp()->m\_pMainWnd; pMainFrame->m\_wndMenuBar.ResetCommandBar(); pMainFrame->m\_wndMenuBar.InsertMenuBar(IDR\_MAINFRAME); pMainFrame->m\_wndMenuBar.LoadToolBar(IDR\_TOOLBAR1);
Thanks again.
I'm glad it helped as I have just noticed that I did not format the code correctly for HTML and therefore some of it is missing.:doh: I'll modify it just for the records! Ant.