Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Dynamically adding ribbon buttons and msgs
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dynamically adding ribbon buttons and msgs

 Post Reply Post Reply
beatle View Drop Down

Joined: 26 May 2005
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote beatle Quote  Post ReplyReply Direct Link To This Post Topic: Dynamically adding ribbon buttons and msgs
    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;



UINT uiGroupTOOLS[] = {m_ToolButtonID};

pCommandBars->GetImageManager()->SetIcons(m_ToolButtonIconID, uiGroupTOOLS, _countof(uiGroupTOOLS), CSize(32, 32));

CXTPToolBar* const pToolBar=pCommandBars->GetToolBar(1);


CXTPRibbonBar* const pRibbonBar=dynamic_cast<CXTPRibbonBar* const>(pToolBar);


CXTPRibbonTab* const pRibbonTab=pRibbonBar->GetTab(4);


CXTPRibbonGroups* const pRibbonGroups=pRibbonTab->GetGroups();


CXTPRibbonGroup* const pRibbonGroup=pRibbonGroups->GetAt(0);


CXTPControl* const pControl=pRibbonGroup->Add(xtpControlButton, m_ToolButtonID);




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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group

Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 18 June 2007 at 1:41am
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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

This page was generated in 0.078 seconds.