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 Tech Support » RibbonMenu question Collapse All
Subject Author Date
tera tera Apr 13, 2009 - 11:43 PM

Hello.


I rebuild RibbonMenu.

Then accelerator key information becomes invalid.

If there is a good method, please teach it.





http://ifreeta.dee.cc/20090414/RibbonBarMDI.lzh


An accelerator key becomes invalid when I execute this code.


 ON_COMMAND ( ID_EDIT_COPY , OnOpTest ) END_MESSAGE_MAP()

// ---------------------------------------------------------------------------- /**  *  @brief  */ // ---------------------------------------------------------------------------- void CMainFrame::OnOpTest() {  m_wndRibbonBar.MenuRebuild ( m_pRibbonNode ); }

void CMyRibbonBar::MenuRebuild( CExtRibbonNode * pRibbonNode ) {  SetButtons( NULL );  SetButtons( pRibbonNode );

 _RecalcPositionsImpl();

 CMDIFrameWnd * pFrame = (CMDIFrameWnd *)AfxGetMainWnd();  OnUpdateCmdUI( pFrame , TRUE ); // !!! THIS LINE WAS ADDED !!!

 RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_ALLCHILDREN );  CExtPaintManager::stat_PassPaintMessages(); };


 

Technical Support Apr 14, 2009 - 11:41 AM

Fixed:

void MenuRebuild( CExtRibbonNode * pRibbonNode )
{
            SetButtons( NULL );
            SetButtons( pRibbonNode );

            VERIFY( MenuInfoGetDefault()-> AccelTableLoad( IDR_MAINFRAME ) ); // THIS LINE WAS ADDED

            _RecalcPositionsImpl();

            CMDIFrameWnd * pFrame = (CMDIFrameWnd *)AfxGetMainWnd();
            OnUpdateCmdUI( pFrame , TRUE ); // !!! THIS LINE WAS ADDED !!!

            RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_ALLCHILDREN );
            CExtPaintManager::stat_PassPaintMessages();
};


tera tera Apr 14, 2009 - 6:19 PM

Hello.


When it is only this

I think that the custom accelerator key to RibbonMenu is erased. 

????


Technical Support Apr 16, 2009 - 1:54 PM

Here is the solution:

   void MenuRebuild( CExtRibbonNode * pRibbonNode )
            {
                        CMemFile _file;
                        CArchive arSave( &_file, CArchive::store );
                        MenuInfoGetDefault()->AccelTableSerialize( arSave );
                        arSave.Close();
                        SetButtons( NULL );
                        SetButtons( pRibbonNode );
                        _file.Seek( 0, CFile::begin );
                        CArchive arLoad( &_file, CArchive::load );
                        MenuInfoGetDefault()->AccelTableSerialize( arLoad );
                        arLoad.Close();
                        _RecalcPositionsImpl();
                        CMDIFrameWnd * pFrame = (CMDIFrameWnd *)AfxGetMainWnd();
                        OnUpdateCmdUI( pFrame , TRUE );
                        RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_ALLCHILDREN );
                        CExtPaintManager::stat_PassPaintMessages();
            };