Print Page | Close Window

runtime extending 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=7604
Printed Date: 21 November 2024 at 3:38pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: runtime extending menu
Posted By: adrien
Subject: runtime extending menu
Date Posted: 15 July 2007 at 11:28pm
Hi
 
I've got a framework that I load components into.  These components may choose to add menu items, or complete sub-menus to the main menu.
 
However, there doesn't seem to be any way to do this? 
 
the code I've seen uses CMenu for all menu manipulation.
 
But there's no way to get the current menu, since with CommandBars, there's no HMENU installed into the main frame HWND, so the call to ::GetMenu(HWND) returns NULL.
 
So i've had to edit XTPMenuBar.h to make m_hMenuDefault public so I can access it (there's no accessor function), but that's really ugly.
 
Do you have any plans to write a real menu class?  One that will be used instead of CMenu.  CMenu is very old and nasty API, like when you append a menu item, it doesn't even give you any reference back to the new item, you have to search for it - hopefully you find the one you just added.
 
I changed my code over to the CodeJock framework specifically to solve this dynamic menu modification problem, but it actually makes it worse, since I can't even call GetMenu any more.
 
any hints?

Adrien
 
 



Replies:
Posted By: adrien
Date Posted: 16 July 2007 at 11:54am

OK

I found out how to add items, and popups.  It's pretty cool, can even set custom icons to a menu item.

One thing that would be really useful though would be an ability to set an LPARAM against a menu item (i.e. add an m_lParam member to CXTPControl)

Then when I get notified of a CXTPControlButton being pressed, I can resolve an associated object and route the message into it.  That way I can add an unlimited number of menu items and menus and not have to use a range of command IDs, or different command IDs with all the associated guff that MFC requires.  By storing my own object in the lparam I'd be able to retrieve it and multiplex all component messages through a single ID.



Posted By: Oleg
Date Posted: 16 July 2007 at 1:36pm

Hi,

you can set custom string pControl->SetParameter or custom integer: pControl->SetTag


-------------
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