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