Link to home
Start Free TrialLog in
Avatar of kjc1111
kjc1111

asked on

OnInitMenuPopup

Hi Experts,

I am trying to use OnInitMenuPopup to dynamically modify my mainframe menus (File, Edit, etc) based on user settings in my application.  However, I'm having a problem with DeleteMenu.  It seems like once I remove a menu item using this command it is permanently gone - it doesn't show up the next time OnInitMenuPopup is called for that menu.  I'd like to have my default menu as the starting point each time OnInitMenuPopup is called and then adjust the settings based on the current settings.  Is there a good way to do this?

Thanks,
Kevin
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

>> It seems like once I remove a menu item using this command it is permanently gone

That is what the DeleteMenu does - it deletes the menu item.  But why should it be a problem, either the user can use that item or they can't so why should you need to keep deleting it.


If the user can somehow change during the running of the app then you could try just disabling the menu item instead.
Avatar of kjc1111
kjc1111

ASKER

Hi Andy,

It is an MDI editing program and there are a lot of menu items available in the app that won't necessariliy be required for each type of file they are editing.  I want to provide a way for the user to customize the functionality for the current file and remove items they don't currently need.  This can even vary from file to file.  I know I can just disable unneeded items but my preference would be to remove them, if possible.  Kind of like toolbars - some apps allow you to dynamically show them or hide them, and if you decide to hide them you can still change your settings to get them back.

Thanks,
Kevin
Hi kjc1111,

IMO there's no generic way to do what you want, at least not in 'old' MFC - is it an option for you to use 'new' MFC (either with VS 2010 or from MFC FeaturePack for VS 2008) using a CMFCMenuBar in your mainframe?

If so I could post you some code how this could work ...

ZOPPO
Avatar of kjc1111

ASKER

Hi Zoppo,

I'm stuck with VC6 since I'm using Stingray Studio as well, and it costs too much to upgrade Stingray so it will support later versions of VS.

Thanks,
Kevin

The only thing I can think of is when your app start you build up some collections of what the current menu's are  (maybe as CMenu objects themselves?).  Then in the OnInitMenuPopup code you have you remove as at present or add if required.

Avatar of kjc1111

ASKER

I noticed that when OnInitMenuPopup is called the nIndex value is always 0 for my mainframe menus.  Is that normal or am I missing a setting somewhere?  If it's normal, is there a way to determine which menu is active, or do I have to do something like check the labels of the menu items for a match to a known value?

Thanks,
Kevin
ASKER CERTIFIED SOLUTION
Avatar of kjc1111
kjc1111

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial