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

runtime extending menu

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


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Topic: runtime extending menu
    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
 
 
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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.

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: 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
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.219 seconds.