Dynamically adding ribbon buttons and msgs |
Post Reply |
Author | |
beatle
Newbie Joined: 26 May 2005 Status: Offline Points: 6 |
Post Options
Thanks(0)
Posted: 16 June 2007 at 1:29pm |
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.
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hello,
It have work same in Ribbon Application - controls send absolutelly same messages.
You can also try catch WM_XTP_COMMAND in CMainFrame and route message to plugin.
wParam - ID of control
lParam - pointer to NMXTPCONTROL.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |