Print Page | Close Window

Get CMenu from CXTPCommandBars?

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=544
Printed Date: 23 December 2024 at 6:52pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Get CMenu from CXTPCommandBars?
Posted By: dmetzler
Subject: Get CMenu from CXTPCommandBars?
Date Posted: 18 March 2004 at 6:33pm

How can I get a CMenu from an existing menu bar?

CXTPCommandBars* pCommandBars = GetCommandBars();

CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar() ;

Now - how to get the CMenu object from the pMenuBar?

Thanks,

Don Metzler

 




Replies:
Posted By: vladsch
Date Posted: 26 March 2004 at 12:40pm

I don't think there is a way to get a CMenu from the current state of the menu bar.

There is a member of CXTPMenuBar m_hMenuDefault that is a menu handle of the default menu loaded into the menu bar but it is set via:

m_hMenuDefault = ::GetMenu(GetSite()->GetSafeHwnd());

So you can just get that yourself without the menu bar.

I don't think this is of help in your case. You can build up a menu from the Controls of the menu bar by reversing the proces of the LoadMenu function in XTPCommandBar.cpp. The function is very simple and straight forward, and would not be a very big job to write its reverse.

Unless you need to pass the CMenu* to a function out of your control it would probably be easier to rewrite your code to deal directly with the XTP classes and functions. Of course unless you don't want to be permanently married to the XTP implementation. 

I did rewrite my code in terms of the XTP classes and it simplified my code enourmously.


 




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