Print Page | Close Window

Dynamically adding ribbon buttons and msgs

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=7389
Printed Date: 25 April 2024 at 8:33am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Dynamically adding ribbon buttons and msgs
Posted By: beatle
Subject: Dynamically adding ribbon buttons and msgs
Date 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.



Replies:
Posted By: Oleg
Date Posted: 18 June 2007 at 1:41am
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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net