Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Menu

Menu

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialhelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rassul Yunussov
    wrote on last edited by
    #1

    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:).

    E A 2 Replies Last reply
    0
    • R Rassul Yunussov

      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:).

      E Offline
      E Offline
      Empty1981
      wrote on last edited by
      #2

      your menu is a popup menu or a mainfram menu

      1 Reply Last reply
      0
      • R Rassul Yunussov

        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:).

        A Offline
        A Offline
        Antony M Kancidrowski
        wrote on last edited by
        #3

        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 also

        return (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.

        R 1 Reply Last reply
        0
        • A Antony M Kancidrowski

          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 also

          return (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.

          R Offline
          R Offline
          Rassul Yunussov
          wrote on last edited by
          #4

          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.

          A 1 Reply Last reply
          0
          • R Rassul Yunussov

            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.

            A Offline
            A Offline
            Antony M Kancidrowski
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups