Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Adding Menu Item at RUN Time
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Adding Menu Item at RUN Time

 Post Reply Post Reply
Author
Message
KumarCJ View Drop Down
Groupie
Groupie
Avatar

Joined: 02 April 2007
Location: India
Status: Offline
Points: 96
Post Options Post Options   Thanks (0) Thanks(0)   Quote KumarCJ Quote  Post ReplyReply Direct Link To This Post Topic: Adding Menu Item at RUN Time
    Posted: 14 August 2007 at 8:33am
Hello,
 
How to add the menu item (say : Sync) in main menu at Run Time.
 
I wanted to add menu item (say : Sync)  in TOOLs menu at Run time. Priviously we used "InsertMenu()".
 
How can I do?
 
 
Thanks,
KumarCJ.
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 14 August 2007 at 10:15am
Hello,
 
to add item to menu:
pMenuBar->GetControls()->Add(xtpControlButton, ID);
 
See \Samples\CommandBars\DynamicPopups  sample.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
KumarCJ View Drop Down
Groupie
Groupie
Avatar

Joined: 02 April 2007
Location: India
Status: Offline
Points: 96
Post Options Post Options   Thanks (0) Thanks(0)   Quote KumarCJ Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2007 at 6:24am

I Tried using the code you suggested

CXTPCommandBar* pMenuBar;
pMenuBar->GetControls()->Add(xtpControlButton, ID);
 
"Sync" menu item is not added in "TOOLs" main menu.
 
It is added after the "HELP" main menu.
 
Once again I am putting the requirement below:
 
Under TOOLs main menu, we have "Trace", "Option", "Customize" menu items.
 
At run time based on some condition I wanted to add the "Sync" menu item under "TOOLs" Main menu after "Trace" and before "Option" menu item and delete "Sync" from "TOOLs" main menu for some condition.
 
I checked the \Samples\CommandBars\DynamicPopups  sample, but I did not found
"pMenuBar->GetControls()->Add(xtpControlButton, ID);".
 
Waiting for your suggestion.
 
Thanks,
KumarCJ
Back to Top
terrym View Drop Down
Senior Member
Senior Member


Joined: 13 April 2007
Status: Offline
Points: 836
Post Options Post Options   Thanks (0) Thanks(0)   Quote terrym Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2007 at 6:33am
Use:
 
pMenuBar->GetControls()->InsertAt(xtpControlButton, nIndex);
 
where nIndex is the item you want to place before
 
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 15 August 2007 at 12:53pm
KumarCJ,
 
pMenuBar->GetControls()->InsertAt, pMenuBar->GetControls()->Add add item to menu.
 
if you need to add to submenu, you need add control to corresponded commandbar:
 
pMenuBar->GetControl(nIndexOfToolsPopup)->GetCommandBar()->GetControls()->Add(...);
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
KumarCJ View Drop Down
Groupie
Groupie
Avatar

Joined: 02 April 2007
Location: India
Status: Offline
Points: 96
Post Options Post Options   Thanks (0) Thanks(0)   Quote KumarCJ Quote  Post ReplyReply Direct Link To This Post Posted: 16 August 2007 at 4:22am
Thanks alot Oleg....
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.078 seconds.