Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 3: Windows Resources


window in which it is used. A main menu is divided in categories of items and each
category is represented by a word. Here is an example:

On the Visual Studio IDE, the categories of menus are File, Edit, View, Project, etc. To
use a menu, the user first clicks one of the words that displays on top. Upon clicking, the
menu expands and displays a list of items that belong to that category. Here is an
example where the View menu of WordPerfect was clicked and got expanded:

There is no strict rule on how a menu is organized, only suggestions. For example,
actions that are related to file processing, such as creating a new file, opening an existing
file, saving a file, printing the open file, or closing the file usually stay under a category
called File. In the same way, actions related to viewing things can be listed under a View
menu.

3.3.3 Main Menu Design.................................................................................


There are two ways you can create a main menu. You can use the Win32 approach in
which case you would create or open your .rc file and create a section as follows:

IDR_MAINFRAME MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", IDM_FILENEW
MENUITEM "&Open", IDM_FILEOPEN
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_FILEEXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About", IDM_HELPABOUT
END
END
Free download pdf