The Application Framework's Built-In Menu Items

You don't have to start each frame menu from scratch—the MFC library defines some useful menu items for you, along with all the command handler functions, as shown in Figure 13-3.

Click to view at full size.

Figure 13-3. The standard SDI frame menus.

The menu items and command message handlers that you get depend on the options you choose in AppWizard. If you deselect Printing and Print Preview, for example, the Print and Print Preview menu items don't appear. Because printing is optional, the message map entries are not defined in the CView class but are generated in your derived view class. That's why entries such as the following are defined in the CMyView class instead of in the CView class:

ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)

Enabling/Disabling Menu Items

The application framework can disable a menu item if it does not find a command message handler in the current command route. This feature saves you the trouble of having to write ON_UPDATE_COMMAND_UI handlers. You can disable the feature if you set the CFrameWnd data member m_bAutoMenuEnable to FALSE.

Suppose you have two views for one document, but only the first view class has a message handler for the IDM_ZOOM command. The Zoom item on the frame menu will be enabled only when the first view is active. Or consider the application framework-supplied Edit Cut, Copy, and Paste menu items. These will be disabled if you have not provided message handlers in your derived view or document class.