In one project I used different Views with different Menus according to which was the active one. I did it creating the menus in the resource editor and then in the MyApp files (.h and .cpp) creating different CMultiDocTemplate one for each type of view, saying which menu was owned by which view.
BOOL CFPSApp::InitInstance()
{
AfxEnableControlContainer();
.
.
//more code
.
.
//Main window menu
pDocTemplate = new CMultiDocTemplate(
IDR_FPSIITYPE,
RUNTIME_CLASS(CFPSDoc),
RUNTIME_CLASS(CChildFrame), // Benutzerspezifischer MDI-Child-Rahmen
RUNTIME_CLASS(CFPSView));
AddDocTemplate(pDocTemplate);
.
//One of the child menu
pParamRegMatTemplate = new CMultiDocTemplate(
IDR_VIEWTYPE, //Special menu for the view
RUNTIME_CLASS(CFPSDoc),
RUNTIME_CLASS(CChildFrame), //Some special features for the view
RUNTIME_CLASS(CParamRegView)); //View for the Regler
AddDocTemplate(pParamRegMatTemplate);
.
//More code
}
this option is good when you know for sure how your project is going to be structured. There are other options to load/unload menus dinamically. If you use it you will have to load/unload the menu in the OnInitialUpdate and when your view loses and wins the focus another time. With the other way I have explained all is done automatically.
Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.