Print Page | Close Window

CXTPMenuBar - need pointer to CMenu

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=14667
Printed Date: 01 April 2025 at 12:47am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPMenuBar - need pointer to CMenu
Posted By: tralfaz
Subject: CXTPMenuBar - need pointer to CMenu
Date Posted: 01 July 2009 at 7:40pm
Is there a way to get my hands on the CMenu associated with the CXTPMenuBar?

OnCreate I'm adding the menu bar:

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

Next I want to modify the Menu and attach custom menu items. If I could get a pointer to a CMenu then I could use my existing routine.

How do you add menu items after the fact?

I need something like this:
   
CXTPMenuBar* pxMenu = GetCommandBars()->GetMenuBar();
CMenu* pMenu = pxMenu->GetMenu();

ModifyMenu(pMenu);

or this

CMenu Menu;
Menu.LoadMenu(IDR_MAINFRAME);
ModifyMenu(&Menu);
CXTPMenuBar* pMenuBar = pCommandBars->SetMenu(&Menu);



Thanks,
Matt


-------------

XP Pro SP3 / VS2008 C++ / Xtreme CommandBars v13.1.0



Replies:
Posted By: rdhd
Date Posted: 02 July 2009 at 10:21am
I don't believe there is a CMenu behind the command bar. You can first use a CMenu to load and manipulate your menu layout and then pass the CMenu to CJ. I do that when building the command ribbon (I might have to get the controls collection and then pass it the menu; I'm not at work so I can't explicitly check on exactly what call I make or whether the call takes in a CMenu or HMENU - CMenu can be cast to HMENU).


Posted By: tralfaz
Date Posted: 07 July 2009 at 11:59am
rd - if you have that call that passes in a CMenu to MenuBar, I'd really appreciate it.

-------------

XP Pro SP3 / VS2008 C++ / Xtreme CommandBars v13.1.0


Posted By: tralfaz
Date Posted: 10 July 2009 at 3:38pm
still waiting for support to get back to me. Is it possible to create a MenuBar from an existing CMenu? Or can I get ahold of a CMenu submenu from a MenuBar?

-------------

XP Pro SP3 / VS2008 C++ / Xtreme CommandBars v13.1.0


Posted By: Oleg
Date Posted: 13 July 2009 at 2:21am
After you converted Menu to CXTPMenuBar you have use methods of CXTPControl/CXTPControls to modify/add items:
 
pMenuBar->GetControl(1)->SetCaption("New Caption");
etc.


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


Posted By: tralfaz
Date Posted: 23 July 2009 at 1:00am
Oleg - your answer leaves a lot to be desired. How am I to create a submenu using GetControl? Seems extremely laborious. Can you elaborate a little?



-------------

XP Pro SP3 / VS2008 C++ / Xtreme CommandBars v13.1.0


Posted By: Oleg
Date Posted: 24 July 2009 at 3:28am

Hi,

See CXTPControls methods - you need "Add" one:
 
pMenuBar->GetControls()->Add(xtpControlPopup, ...);
 


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



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