Print Page | Close Window

Dynamic menu

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=834
Printed Date: 06 March 2025 at 4:15am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Dynamic menu
Posted By: yoavo
Subject: Dynamic menu
Date Posted: 14 June 2004 at 1:36am

Hi,

In my application I create the menu in run-time (not loading from resources). I want my menu to be CXTPMenuBar. (SetMenu of CXTPCommandBars needs a resource ID...)

How can I do that ?

thanks, Yoav.




Replies:
Posted By: Oleg
Date Posted: 18 June 2004 at 2:51am
pMenuBar->GetControls()->Add(..)

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: yoavo
Date Posted: 20 June 2004 at 12:54am

I dont think I understand what you mean. I created a CMenu object(not loaded from resources), and I need it to be attached to a CXTPMenuBar.

How do I create the CXTPMenuBar ? (it seems that the only way for me to create one is by CXTPCommandBars::SetMenu, which needs a resource ID...)

 



Posted By: Oleg
Date Posted: 21 June 2004 at 1:39am
You also can use pMenuBar->LoadMenu.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: yoavo
Date Posted: 21 June 2004 at 11:32pm

I tried to create a CXTPMenuBar and attach it to a CMenu object, but it does not work (I think that some stuff is done in CXTPMenuBar::LoadMenuBar which I can not do).

Can you give me a sample code of creating a CXTPMenuBar, attaching it to a CMenu object, and setting it on the Frame window ?



Posted By: yoavo
Date Posted: 22 June 2004 at 7:50am
Sorry, no need for a sample. I figure out how it is working.


Posted By: superppy
Date Posted: 11 July 2004 at 6:07am

Simple example of dynamic menu :

CXTPMenuBar* pMenuBar = GetCommandBars()->GetMenuBar();

pMenuBar->GetControls()->RemoveAll();

UINT nCmdID = 0x8000;

CMenu mainMenu;

mainMenu.CreateMenu();

CMenu fileMenu;

fileMenu.CreateMenu();

fileMenu.AppendMenu(MF_STRING, nCmdID++, "Open");

fileMenu.AppendMenu(MF_SEPARATOR, 0, "");

fileMenu.AppendMenu(MF_STRING, nCmdID++, "New");

mainMenu.AppendMenu(MF_POPUP, (UINT)fileMenu.GetSafeHmenu(), "File");

CMenu editMenu;

editMenu.CreateMenu();

editMenu.AppendMenu(MF_STRING, nCmdID++, "Cut");

editMenu.AppendMenu(MF_STRING, nCmdID++, "Paste");

mainMenu.AppendMenu(MF_POPUP,(UINT)editMenu.GetSafeHmenu(), "Edit");

pMenuBar->GetControls()->AddMenuItem(&mainMenu, 0);

pMenuBar->GetControls()->AddMenuItem(&mainMenu, 1);

 



Posted By: djtompa
Date Posted: 29 November 2004 at 5:30am

If I have created a menu as stated by superppy then how can I add icons. I tried the following:

int nIDIcons[] = {nCmdID};

XTPImageManager()->SetIcons(bitmapID, (UINT*) &nIDIcons, sizeof(nIDIcons)/sizeof(nIDIcons[0]), CSize(16, 16));

But no icons are shown. Whats wrong?

thank you
tom



Posted By: SuperMario
Date Posted: 01 December 2004 at 9:12am
nIDIcons is an array of ids for controls in your menu.  It looks like you only have one id in your array.  You need an id for each icon in the bitmap resource.  Check that the id given to your menu controls match the ids in the nIDIcons array.


Posted By: djtompa
Date Posted: 07 December 2004 at 11:12am

Thank you for your help, but that doesnt seem to be the problem:

if I take a nCmdID which belongs to the programs toolbar it wokrs perfectly. It just doesnt work with the cmdIds I generate during the creation of my contect menu. Do I somehow have to "tell" the XTPImageManger which cmdIds I create or something like that?




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