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
Author
Message
beatle View Drop Down
Newbie
Newbie


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;

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

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
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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.063 seconds.