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 » a bug of CExtRibbon Collapse All
Subject Author Date
tera tera Mar 31, 2009 - 4:48 AM


I made a dynamic menu.

A menu increases and decreases when I push Dynamic-Menu1.

Assert appears when I push Dynamic-Menu2 many times.

In addition, when I test it in application for release.

The application does Assert immediately.

Please cope as soon as possible

I sent the source by an email.


Technical Support Mar 31, 2009 - 10:35 AM

How did you implement your dynamic menu?

We would recommend the following approach:

1) Create only one menu node in the popup menu displayed by the ribbon button. This menu node is called a menu marker item. It’s the menu command item and it should have some known ID_MY_REPLACE_CMD command identifier.

2) Handle the CExtPopupMenuWnd::g_nMsgPrepareMenu registered message like described here:

But you should handle it in your CExtRibbonBar-derived class instead of the main frame class.

tera tera Mar 31, 2009 - 6:31 PM


The dynamic menu is not a pop-up menu.

I make a ribbon menu display and non-display.

I ask for a test with a sample.

When I click a pop-up menu of Dynamic-Menu2.

Display and the non-display handling of ribbon menu run.

It is the same as Dynamic-Menu1.

However, when I carry it out in Dynamic-Menu2 many times

Fatal Assert appears.

It occurs by release frequently.  

I am troubled.  Give my best regards


Technical Support Apr 2, 2009 - 2:18 PM

We modified the RibbonBar sample application for you:

This modified sample application has the new ribbon button displaying dynamically constructed popup menu. The new ribbon button can be seen in the Clipboard group of buttons inside the Home ribbon tab page. First of all, we inserted the following code into the CMainFrame::_InitRibbonNode_Home_Clipboard() method for inserting new ribbon button into the ribbon bar:

CExtRibbonNode * pDynMenuRibbonButton = new CExtRibbonNode( 123, 0, NULL, 0, _T("Button with dynamic menu") );
            pDynMenuRibbonButton->RibbonILE_RuleRemoveEntriesByILV( true, false, true );
            pDynMenuRibbonButton->InsertNode( &m_wndRibbonBar, new CExtCustomizeCmdTreeNode( 124, 124 ) );
            pRibbonGroup->InsertNode( NULL, pDynMenuRibbonButton );

Second, we implemented the WindowProc() virtual method in the CMainFrame class for initializing popup menu of the ribbon button on the fly, just before it appears on the screen:
   virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
                        if( message == CExtPopupMenuWnd::g_nMsgPrepareMenu )
                                    CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
                                                reinterpret_cast < CExtPopupMenuWnd::MsgPrepareMenuData_t * > ( wParam );
                                    ASSERT( pData != NULL );
                                    CExtPopupMenuWnd * pPopup = pData->m_pPopup;
                                    ASSERT( pPopup != NULL );
                                    INT nReplacePos = pPopup->ItemFindPosForCmdID( 124 );
                                    if( nReplacePos >= 0 )
                                                pPopup->ItemRemove( nReplacePos );
                                                pPopup->ItemInsertCommand( 1000, nReplacePos + 0, _T("Dynamically created menu item 1") );
                                                pPopup->ItemInsertCommand( 1001, nReplacePos + 1, _T("Dynamically created menu item 2") );
                                                pPopup->ItemInsertCommand( 1002, nReplacePos + 2, _T("Dynamically created menu item 3") );
                                                pData->m_bMenuChanged = true;
                                                return 1L;
                        return CExtNCW < CFrameWnd > :: WindowProc( message, wParam, lParam );
That’s all. Please note, the 124 command identifier value is used in the both code snippets and maker menu item identifier.