Articles and Tutorials

Add MDI Menus customization

Author: Kirk Stowell
Platform: Visual C++ MFC

Command Bars has three ways for developers to add MDI Menu customization menus. This tutorial assumes that you have already created an application with customization. Click here for more information about this.

Standard MDI Menu customization:

This method uses the MFC architecture for MDI menus, you just need to add standard customization without additional changes. As in a standard MFC application, you must add templates for each MDI document type

Advantages:
  • Ease to add customization
  • Ease to modify standard MFC application
Disadvantages:
  • All disadvantages belong to the user-side. Users must manually customize all templates in the application. For example if the users want to see ‘View’ popup before ’File‘ they must customize each doc template and Main Frame template.
Notes:
  • Be sure that when you create a menu you use a Main Frame identifier
    CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
        _T("Menu Bar"), IDR_MAINFRAME);
    
  • See the CustomizeDlg sample for this customization type
  • xtpFlagUseMDIMenus flag no longer used

Static MDI Menu customization:

All you need is to add the xtpFlagIgnoreSetMenuMessage flag to the Menu Bar:

 CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
     _T("Menu Bar"), IDR_CUSTOMTYPE); 
 pMenuBar->SetFlags(xtpFlagIgnoreSetMenuMessage);

and all other menu templates will be ignored.

Advantages:
  • Ease to add customization
  • Ease to modify standard MFC application
  • Easy for users to customize the application, because they need customize only a single menu used for all templates
Disadvantages
  • Static menus not very flexible for developers to apply some document types
Notes:
  • See CustomThemes sample for this customization type

Custom MDI menu customization:

This is the most difficult for developers, but the most friendly type for user customization.

Developers must create only one Menu template with all popup items needed to be used in the application, and assign programmatically what popup items are shown in each template.

For example developers must add the ‘Window’ item but assign it to show only when some documents are visible.

For this customization type add ExcludeDocTemplate and AssignDocTemplate methods of CXTPControl class.

Advantages:
  • Easy for users to customize the application, because they need customize only a single menu to be used for all templates
Disadvantages
  • Developers must manually assign the popup items that are visible when the document template is active
Notes:
  • Visual Studio 6.0 and .NET used such customization type. (If you customize the ‘File’ item and open some image to edit, a new ‘Image’ popup appears but the changes in the File section stay the same.)
  • See MDIMenus sample for this customization type

See Also: Add customization to menus and toolbars

Articles and Tutorials