runtime extending menu |
Post Reply |
Author | |
adrien
Senior Member Joined: 30 April 2007 Location: New Zealand Status: Offline Points: 449 |
Post Options
Thanks(0)
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 |
|
adrien
Senior Member Joined: 30 April 2007 Location: New Zealand Status: Offline Points: 449 |
Post Options
Thanks(0)
|
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. |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi, you can set custom string pControl->SetParameter or custom integer: pControl->SetTag
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |