Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,
I have an application using VC++ version 6, with MFC, and would like to change the main menu depending on user selection. What is the best way doing this? Any examples?

Thanks
Neil
Posted
Updated 28-Apr-10 23:55pm
v2

I think the best way is to populate a menu with all possible options, and set their visibility based on the user selection.
 
Share this answer
 
My experience is that users don't like it when controls (or menu items) appear and disappear while they're using the program. At the very most, they are just barely comfortable with items being disabled, but when things start disappearing/reappearing, they freak out. I'd rethink my interface if I were you.
 
Share this answer
 
If your target is to change the menu at compile time, the best is to create your menus with the resource editor, using the same ID for all of them, and using the Condition property of them (you find the Condition property on the Property window).

This way the resource editor generates an rc file with the #ifdef required to compile or not your menus depending on the resource compiler pre-processor macro that you put inside the Condition property.

Note that the pre-processor macro used by the resource compiler are not the same that the C/C++ compiler uses: you should define them on the Resource tab of your project properties.
 
Share this answer
 
Sorry.. My mistake.. I have 3 various menus in which I want to select during compiling application by passing a flag to the compiler, then the required menu will always be the main menu.

Neil
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900