CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Aug 2006
    Posts
    515

    How to dynamically load main menu in MDI

    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.
    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);
    }
    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?

    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.
    Last edited by zspirit; March 6th, 2012 at 04:46 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured