Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » How to hide ribbon tabs/pages? Collapse All
Subject Author Date
Robert Webb Oct 2, 2008 - 4:18 AM


This is urgent (conference next week).

What is the right way, if there is one, to show/hide ribbon tabs on the fly?

I tried using this:

            child->ModifyFlags(0, __ECTN_TBB_HIDDEN);

Which then needs these:

    CExtRibbonNode *root = m_pRibbonNode;

But when calling Ribbon_PageSelectionSet(), either directly or indirectly when the user clicks on a tab, it causes an assertion and can then crash.  Here’s where it stops:

bool CExtRibbonBar::Ribbon_PageSelectionSet(
    INT nNewSelIdx,
    bool bEnableAnimation // = true
    ASSERT_VALID( this );
CExtRibbonNodeTabPageCollection * pColNode = Ribbon_GetTabPageRootNode();
    if( pColNode == NULL )
        return false;
INT nPageIndex, nPageCount = pColNode->GetNodeCount();
    ASSERT( nPageCount == RibbonTabPageButton_GetCount() );  // <---- This fails

It seems that nPageCount is the total number of tabs including hidden ones, and RibbonTabPageButton_GetCount() doesn’t include the hidden ones.

Is it not possible to hide tabs on the fly?



Technical Support Oct 7, 2008 - 4:53 AM

The [_][o][x] buttons in the command tree are represented by one CExtRibbonNodeMdiRightButtons node. This node is placed in the group of buttons on the right side of the tab item like buttons. So, the problem with disappeared [_][o][x] buttons is outside your code which manages the collection of tab nodes. We suspect you may have forgotten to invoke ribbon bar’s UpdateMenuBar() method after changing its structure of buttons.

Robert Webb Oct 16, 2008 - 1:27 AM

Ah, thanks!  Yes, UpdateMenuBar() is what I needed.  It’s not that I forgot to call it.  Rather I didn’t know it existed.


Technical Support Oct 3, 2008 - 9:15 AM

We fixed this issue. Now the ribbon bar supports hidden tab pages. Please drop us an e-mail to so we will provide you with the source code update download.

Robert Webb Oct 2, 2008 - 7:30 PM

One alternative for me would be to keep a list of all the page nodes, and refill the page collection as required.  That is, rather than hiding pages, I would remove them altogether.  However, I can’t see how to remove a page from the page collection without actually deleting the node.  Functions like RemoveAllNodes() actually delete the nodes.

Can nodes be removed as children without being deleted?



Technical Support Oct 3, 2008 - 1:47 PM

No. The CExtCustomizeCmdTreeNode::RemoveNodes() method removes nodes and deletes them. The CExtCustomizeCmdTreeNode class does not support detaching of children nodes. We didn’t add this feature because nodes are small C++ objects in memory and we supposed nobody would try to save tree leaves for some optimization.

Robert Webb Oct 5, 2008 - 11:51 PM

I managed to write my own code to remove pages from a ribbon bar without deleting it.  I derived a new class from CExtRibbonNodeTabPageCollection and gave it this member function:

// Remove all child nodes without deleting them.
void CMyPageCollection::DetachChildren()
    CExtCustomizeCmdTreeNode *child;
    int i, num = m_arrChilds.GetSize();
    for (i = 0; i < num; i++)
        child = DYNAMIC_DOWNCAST(CExtCustomizeCmdTreeNode, m_arrChilds.ElementAt(i));
        if (child != NULL)
    m_arrChilds.RemoveAt(0, num);

Calling this function will detach all the children without deleting them.  I then keep a list of the tabs required in a couple of different modes and re-insert them as required when changing modes.  Currently I do it like this:

    CMyPageCollection *tabs = DYNAMIC_DOWNCAST(CMyPageCollection, Ribbon_GetTabPageRootNode());
    CExtRibbonNode *root = Ribbon_GetRootNode();
    <for each tab in this mode>
        SafeInsert(tabs, tab);

However, one problem now arises, which is that the MDI buttons to the right of the tabs become hidden.  When changing modes (which executes the above code) they appear for a moment and then disappear again.  I tried removing the __ECTN_TBB_HIDDEN flag from Ribbon_GetRightRootNode() and its children, but it didn’t help.

Any idea what’s going on here?

Thanks for the fix for hiding tabs.  I’ve emailed support and will check that

out too.