Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Adding toolbar button dynamically
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Adding toolbar button dynamically

 Post Reply Post Reply
Author
Message
sabapathy View Drop Down
Newbie
Newbie


Joined: 12 November 2009
Location: India
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote sabapathy Quote  Post ReplyReply Direct Link To This Post Topic: Adding toolbar button dynamically
    Posted: 29 May 2010 at 2:38am
I would like to add a button dynamically in the toolbar of my SDI application.
The toolbar type is CXTPToolBar.
How can do it and specify the style & type of control.
 
Thanks
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: 30 May 2010 at 3:14am
Hi,

just
pToolBar->GetControls()->Add(xtpControlButton, ...);
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
FrankC View Drop Down
Groupie
Groupie


Joined: 04 September 2008
Location: United States
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote FrankC Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2011 at 4:33pm
Thanks Oleg.

According to your suggestion, I have tried the following code when creating the mainframe menubar.

However, the added button does not show up.  Do you think these code are correct?

Thanks,
Frank

CXTPCommandBars* pCommandBars = GetCommandBars();

CXTPMenuBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);

CXTPControls* pzMenuControls = pMenuBar->GetControls();

CXTPControl* pNewControl = pzMenuControls->Add(xtpControlButton, 100, "Manage");

DWORD dwFlags = pNewControl->GetFlags();

dwFlags |= xtpFlagRightAlign;

pNewControl->SetFlags(dwFlags);

pNewControl->SetVisible(TRUE);
Back to Top
FrankC View Drop Down
Groupie
Groupie


Joined: 04 September 2008
Location: United States
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote FrankC Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2011 at 5:58pm
Solved.

I have to clean the previously saved menu settings.

Thanks,
Frank
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.