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. Show and Hide the Menu bar dynamically

Show and Hide the Menu bar dynamically

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestionlearning
3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • L Lost User

      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

      P Offline
      P Offline
      pc_dev
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • P pc_dev

        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

        M Offline
        M Offline
        mclpun
        wrote on last edited by
        #3

        Hi Freind, Thanks. But I only successfully hide the Menu, but not showing it again. Do I just need to replace "pMenu->DeleteMenu(0, MF_BYPOSITION);" to "pMenu->AppendMenu(0, MF_BYPOSITION);" without changing other code? Cheers

        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