Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Dynamic menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dynamic menu

 Post Reply Post Reply
Author
Message
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post Topic: Dynamic menu
    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.

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: 18 June 2004 at 2:51am
pMenuBar->GetControls()->Add(..)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post 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...)

 

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: 21 June 2004 at 1:39am
You also can use pMenuBar->LoadMenu.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post 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 ?

Back to Top
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post Posted: 22 June 2004 at 7:50am
Sorry, no need for a sample. I figure out how it is working.
Back to Top
superppy View Drop Down
Newbie
Newbie


Joined: 11 July 2004
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote superppy Quote  Post ReplyReply Direct Link To This Post 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);

 



Edited by superppy
Back to Top
djtompa View Drop Down
Newbie
Newbie
Avatar

Joined: 29 November 2004
Location: Germany
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote djtompa Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
djtompa View Drop Down
Newbie
Newbie
Avatar

Joined: 29 November 2004
Location: Germany
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote djtompa Quote  Post ReplyReply Direct Link To This Post 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?

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.