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. How to disable entire menu bar.

How to disable entire menu bar.

Scheduled Pinned Locked Moved C / C++ / MFC
designtutorial
2 Posts 2 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.
  • S Offline
    S Offline
    shivditya
    wrote on last edited by
    #1

    I am developing a software in which, each menu opens a panel(dialog) and user is suppose to not access the other menu ,unless he closes dialog. So by the time one panel is active ,it is required to deactivate entire menubar. I am using SDI and modified default menu bar for same. I was not able to find any method to directly deactivate. But whatever I found that is also not working. My entire toolbar I was able to disable,but not menu bar. Also I like to know how to disable individual button of toolbar. void CMainFrame::OnAddCustomer() { CToolBarCtrl& ctb = m_wndToolBar.GetToolBarCtrl(); ctb.EnableWindow(FALSE); ctb.PressButton(ID_ADD_CUSTOMER,true); CMenu* cmu = this->GetMenu(); UINT ui = cmu->EnableMenuItem(ID_ADD_CUSTOMER,MF_DISABLED);

    || ART OF LIVING ||

    M 1 Reply Last reply
    0
    • S shivditya

      I am developing a software in which, each menu opens a panel(dialog) and user is suppose to not access the other menu ,unless he closes dialog. So by the time one panel is active ,it is required to deactivate entire menubar. I am using SDI and modified default menu bar for same. I was not able to find any method to directly deactivate. But whatever I found that is also not working. My entire toolbar I was able to disable,but not menu bar. Also I like to know how to disable individual button of toolbar. void CMainFrame::OnAddCustomer() { CToolBarCtrl& ctb = m_wndToolBar.GetToolBarCtrl(); ctb.EnableWindow(FALSE); ctb.PressButton(ID_ADD_CUSTOMER,true); CMenu* cmu = this->GetMenu(); UINT ui = cmu->EnableMenuItem(ID_ADD_CUSTOMER,MF_DISABLED);

      || ART OF LIVING ||

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      You could use MFC command enablers. This should enable/disable both toolbar and menu items...

      // Add to CMainFrame class
      afx_msg void OnUpdateDbconnect(CCmdUI* pCmdUI);
      ...
      // Add to CMainFrame's message map
      BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
      ON_UPDATE_COMMAND_UI(ID_ADD_CUSTOMER, OnUpdateAddCustomer)
      END_MESSAGE_MAP()
      ...
      // Add the handler method
      void CMainFrame::OnUpdateAddCustomer(CCmdUI* pCmdUI)
      {
      if (...some condition...)
      pCmdUI->Enable(FALSE); // disable
      else
      pCmdUI->Enable(TRUE); // enable
      }

      See the ON_UPDATE_COMMAND_UI/ON_UPDATE_COMMAND_UI_RANGE macros in the docs. You can also disable thw main window EnableWindow(FALSE); That's what MFC does to simulate modal dialogs. Mark

      Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3

      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