Chapter 14. Working with Menus and Toolbars
In the last chapter, you saw how a simple framework application generated by the MFC Application Wizard is made up and how the parts interrelate. In this chapter, you'll start customizing a Multiple Document Interface (MDI) framework application called Sketcher with a view to making it into a useful program. The first step in this process is to understand how menus are defined in Visual C++ 2008, and how functions are created to service the application-specific menu items that you add to your program. You'll also see how to add toolbar buttons to the application. By the end of this chapter, you'll have learned about:
How an MFC-based program handles messages
Menu resources, and how you can create and modify them
Menu properties, and how you can create and modify them
How to create a function to service the message generated when a menu item is selected
How to add handlers to update menu properties
How to add toolbar buttons and associate them with existing menu items
Communicating with Windows
As you saw in Chapter 12, Windows communicates with your program by sending messages to it. Most of the drudgery of message handling is taken care of by MFC, so you don't have to worry about providing a WndProc()
function at all. MFC enables you to provide functions to handle the individual messages that you're interested in and to ignore the rest. These functions are referred to as message handlers or just handlers. Because your application is MFC-based, ...
Get Ivor Horton's Beginning Visual C++®2008 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.