The Application Framework's Built-in Menu Commands
You don't have to start each frame menu from scratch—the MFC library defines some useful menu commands for you, along with all the command handler functions, as shown in Figure 12-3.
Figure 12-3: The standard SDI frame menus.
The menu commands and command message handlers that you get depend on the options you select in the MFC Application Wizard. If you deselect Printing And Print Preview, for example, the Print and Print Preview commands won'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 and Disabling Menu Commands
The application framework can disable a menu command 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 command on the frame menu will be enabled only when the first view is active. Or consider the Edit Cut, Copy, and Paste commands, which are supplied with the application framework. These will be disabled if you haven't provided message handlers in your derived view or document class.