views:

318

answers:

3

Hi,

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

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

EDIT:

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

A: 

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
mem64k
+2  A: 

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
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
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
A: 

Hi, Sir. can I remove a element from CMFCRibbonButtonsGroup? after Add a CMFCRibbonButtonsGroup, I want to remove a element CMFCRibbonButton but I can not remove it. how can I do? for example: // Create a new group with 2 elements: font name and font size: CMFCRibbonButtonsGroup* pFontGroup = new CMFCRibbonButtonsGroup; CMFCRibbonFontComboBox* pFontCombo = new CMFCRibbonFontComboBox(ID_FONT_CHANGE); pFontGroup->AddButton(pFontCombo); CMFCRibbonComboBox* pFontSizeCombo = new CMFCRibbonComboBox(ID_FONT_SIZE, TRUE, 39); pFontGroup->AddButton(pFontSizeCombo); pPanelFont->Add(pFontGroup);

and then I want to remove "pFontSizeCombo" in runtime.

Joong
Yes, but you need to overwrite the CMFCRibbonButtonsGroup class and add RemoveButton(CMFCRibbonBaseElement* pButton) function. The class CMFCRibbonButtonsGroup don't provide this functionality itself.
mem64k