Professional UI Solutions
Site Map   /  Register
 
 

Forum

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 General Discussion » Add/remove Nodes to/from RibbonBar dynamically Collapse All
Subject Author Date
Stephan Wieland Jun 17, 2010 - 2:49 AM

Hello,


I have problems to add and remove nodes to or from RibbonBar dynamically.


I tried so:


void CMainFrame::UpdateRibbon(void)

{

   int iNodes = 0;



   ...


    // Get Group...

    CExtCustomizeCmdTreeNode * pRibbonNodeTabPageCollection = m_pRibbonNode->ElementAt(0);

    CExtCustomizeCmdTreeNode * pRibbonNodeTabPage = pRibbonNodeTabPageCollection->ElementAt(0);

    CExtCustomizeCmdTreeNode * pRibbonGroup = pRibbonNodeTabPage->ElementAt(1);



   

   // remove all nodes from group

    pRibbonGroup->RemoveAllNodes();



    // get number of objects

    int iCount = GetNumberObjects();



    for(int i=0; i<iCount; i++)

    {

        CXObject* pObj = GetObjectAt(i);

        if(pObj)

        {

                pRibbonGroup->InsertNode(

                    NULL,

                    CreateRibbonNode(pObj->m_strBez1, (char)(0x30+iNodes), IDX_START_OBJ+iNodes, IDX_START_OBJ, NULL)

                    );

                iNodes++;

        }



    }



    m_wndRibbonBar.SetButtons(NULL);

    m_wndRibbonBar.SetButtons(m_pRibbonNode);

    m_wndRibbonBar._RecalcPositionsImpl();

    //m_wndRibbonBar.Ribbon_UpdateLayout();

    CWnd::RepositionBars(0,0xFFFF,0);

    m_wndRibbonBar.Invalidate();

       

}


 


But there´s an assertion in


             SetButtons(NULL);


 


Can you please help me?


Best regards


SW

Technical Support Jun 19, 2010 - 11:46 AM

Your code modifies the nodes of an existing command tree which is already assigned to the ribbon bar. Then it invokes the m_wndRibbonBar.SetButtons(NULL); code which deletes ribbon bar buttons. Some of ribbon bar buttons contain references to the ribbon nodes which you already deleted before invoking the m_wndRibbonBar.SetButtons(NULL); code. So, you should invoke the m_wndRibbonBar.SetButtons(NULL); code first. Then modify the command tree. Finally, assign modified tree to the ribbon bar.