I want to dynamically load the main menu (the new manu is in different language) but I can't get passed the GetMenu() call because it alwasy return 0. Here is the code that I am running.
My problem is that my pMenuCurrent is always zero so I can't get anywhere. I googled this quite a bit and everyone is usins GetMenu() to access the current menu but I always 0 for it. What could I be missing?Code:void CMainFrame::OnButtonGerman() { CMenu *pMenuCurrent = GetMenu(); // has the menu changed? // m_hMenuDefault is the default menu resource for this frame see AFXWIN.H if(pMenuCurrent->m_hMenu != m_hMenuDefault) { // Destroy the "New" menu and delete the resource // We, after all created it! pMenuCurrent->DestroyMenu(); delete pMenuCurrent; } // Load our new men from another resource now m_pMenuNew.LoadMenu(IDR_MAINFRAME2); // Displauy the new menu SetMenu(m_pMenuNew); }
Note: In this example I am just reloading the menu from a different resource. Once I have this working I will load the new resource from my satellite dll for that language.
Update:
This happens only in VC2010. I tried same in VC2005 and it works there.




Reply With Quote