Has anyone figured out if it's possible to either hide, show, add or remove a button from the ribbon bar at run time? Is it possible? I'd like to have a button only show up in DEBUG builds.
10 years ago, before ribbon resource files were introduced, adding buttons programmatically in CMainFrame::OnCreate
was actually the only way, if you opted for a ribbon gui. Would have looked like this:
CMFCRibbonMainPanel* pMainPanel = m_wndRibbonBar.AddMainCategory (_T("File"), IDB_TOOLBAR_16, IDB_TOOLBAR_32);
pMainPanel->Add (new CMFCRibbonButton (ID_FILE_NEW, "&New\nStrg+N", 0, 0));
pMainPanel->Add (new CMFCRibbonButton (ID_FILE_OPEN, "&Open...\nStrg+O", 1, 1));
pMainPanel->Add (new CMFCRibbonButton (ID_FILE_SAVE, "&Save\nStrg+S", 2, 2));
pMainPanel->Add (new CMFCRibbonButton (ID_FILE_SAVE_AS, "Save &as\nStrg+U", 3, 3));
#ifdef _DEBUG
pMainPanel->Add (new CMFCRibbonButton (ID_FILE_DEBUG_INFO, "Show &Debug Information\nStrg+D", 4, 4));
#endif