Print Page | Close Window

Adding Menu Item at RUN Time

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=7796
Printed Date: 13 November 2025 at 11:56am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Adding Menu Item at RUN Time
Posted By: KumarCJ
Subject: Adding Menu Item at RUN Time
Date 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.



Replies:
Posted By: Oleg
Date 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


Posted By: KumarCJ
Date 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


Posted By: terrym
Date 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


Posted By: Oleg
Date 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


Posted By: KumarCJ
Date Posted: 16 August 2007 at 4:22am
Thanks alot Oleg....



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