1

I'm looking for a trick to remove an CMFCRibbonPanel from CMFCRibbonCategory. There is just the AddPanel() function in the CMFCRibbonCategory, but no RemovePanel().

Do I really need to rebuild my whole CMFCRibbonCategory to do this?

Just for clarification, what I want is to remove the panel itself from the category and not the elements from the panel.

mem64k
  • 748
  • 1
  • 11
  • 25

2 Answers2

3

In my case I did end up rebuilding the category from scratch. In the CMFCRibbonCategory source code (look for afxribboncategory.cpp) there is no apparent way to remove a panel from the panels array.

djeidot
  • 4,542
  • 4
  • 42
  • 45
  • Yea, I also end up by this solution! I added connect request! Please vote here: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=419881 – mem64k Mar 06 '09 at 12:14
  • Me too. But I didn't really mind because I wanted to remove ALL panels, so I just added a new category and removed the old one. But still not as good as CMFCCategory::RemoveAllPanels would have been... – demoncodemonkey Mar 27 '09 at 14:50
1

I don't know anything about CMFCRibbonPanel and CMFCRibbonCategory. After seeing the class declaration in MSDN I thought you can get a reference to CMFCRibbonPanel from CMFCRibbonCategory and call CMFCRibbonPanel::RemoveAll on the pointer.

CMFCRibbonCategory *pCategory = m_wndRibbonBar.GetCategory(0);

if (pCategory)
{
     CMFCRibbonPanel *pPanel = pCategory->GetPanel(0);

     if (pPanel)
     {
        pPanel->RemoveAll();
        m_wndRibbonBar.AdjustSizeImmediate();
     }
}
Vinay
  • 4,743
  • 7
  • 33
  • 43
  • 1
    I want to remove pPanel itself and not the elements in the panel. BTW: You should use while (pPanel->GetCount()) { VERIFY(pPanel->Remove(0)); } insted of pPanel->RemoveAll(); see https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=377527&wa=wsignin1.0 – mem64k Feb 26 '09 at 16:27
  • I know this is like 3 years ago, anyway thanks for helping me in the future. – Joey Arnold Andres Jul 26 '12 at 23:08