Chapter 4 -- Menus

[Previous] [Next]

Chapter 4

Up to now, the programs we've developed have lacked an important feature found in nearly every Microsoft Windows application: a menu. It's time to remedy that omission by learning how to incorporate menus into our code.

Drop-down menus may be the most widely recognized user interface element in the world. Nearly everyone who sits down in front of a computer and sees a menu knows that clicking an item in the menu bar displays a drop-down list of commands. Even novice computer users quickly catch on once they see menus demonstrated a time or two. Many computer users remember what it was like to use a new MS-DOS application—learning unintuitive key combinations and memorizing obscure commands to carry out basic tasks. Menus, which sprang out of research at Xerox's famed Palo Alto Research Center (PARC) in the 1970s and were popularized by the Apple Macintosh in the 1980s, make computers vastly more approachable by making concise lists of commands readily available and allowing users to select those commands through the simple act of pointing and clicking. Menus aren't required in Windows programs, but they contribute to ease of use. The more complicated the program and its command structure, the more likely it is to benefit from a menu-based user interface.

Because menus are such an important part of the user interface, Windows provides a great deal of support to applications that use them. The operating system does the bulk of the work involved in managing menus, including displaying the menu bar, dropping down a menu when an item on the menu bar is clicked, and notifying the application when a menu item is selected. MFC further enhances the menu processing model by routing menu item commands to designated class member functions, providing an update mechanism for keeping menu items in sync with the state of the application, and more.

We'll begin this chapter by reviewing the fundamentals of menu handling and building a rudimentary program that features a menu. Then we'll move on to more advanced topics and build a second application, one that offers a few bells and whistles.



Programming Windows with MFC
Programming Windows with MFC, Second Edition
ISBN: 1572316950
EAN: 2147483647
Year: 1999
Pages: 101
Authors: Jeff Prosise

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net