I have an application that I'm converting to use ribbon bars. The application loads up plug-ins DLL's and for each one adds a button to a ribbon bar. The code is as follows:
CXTPCommandBars* const pCommandBars=pPlugInComponentContext->m_pCommandBars;
_ASSERTE(pCommandBars);
pCommandBars->GetImageManager()->SetIcons(m_ToolButtonIconID);
UINT uiGroupTOOLS[] = {m_ToolButtonID};
pCommandBars->GetImageManager()->SetIcons(m_ToolButtonIconID, uiGroupTOOLS, _countof(uiGroupTOOLS), CSize(32, 32));
CXTPToolBar* const pToolBar=pCommandBars->GetToolBar(1);
_ASSERTE(pToolBar);
CXTPRibbonBar* const pRibbonBar=dynamic_cast<CXTPRibbonBar* const>(pToolBar);
_ASSERTE(pRibbonBar);
CXTPRibbonTab* const pRibbonTab=pRibbonBar->GetTab(4);
_ASSERTE(pRibbonTab);
CXTPRibbonGroups* const pRibbonGroups=pRibbonTab->GetGroups();
_ASSERTE(pRibbonGroups);
CXTPRibbonGroup* const pRibbonGroup=pRibbonGroups->GetAt(0);
_ASSERTE(pRibbonGroup);
CXTPControl* const pControl=pRibbonGroup->Add(xtpControlButton, m_ToolButtonID);
_ASSERTE(pControl);
pControl->SetFlags(xtpFlagManualUpdate);
pControl->SetEnabled(TRUE)
The first problem I had was the button wasn't enabled because there is no message handler, this is by design since I don't know where the messages are to be routed at compile time. So I used SetEnabled to enable the button. The problem I now face is getting messages. In the original application I trapped the WM_COMMAND messages in OnCmdMsg and looked for the ID (m_ToolButtonID), but in the ribbon application I get nothing.
Some help would be much appreciated, I have been struggling with this for nearly a week.
Thanks in advance.
|