SUMMARY

In this chapter, you learned how MFC connects a message with a class member function to process it, and you wrote your first message handlers. Much of the work in writing a Windows program is writing message handlers, so it’s important to have a good grasp of what happens in the process. When we get to consider other message handlers, you’ll see that the process for adding them is just the same.

You have also extended the standard menu and the toolbar in the MFC Application Wizard–generated program, which provides a good base for the application code that you add in the next chapter. Although there’s no functionality under the covers yet, the menu and toolbar operation looks very professional, courtesy of the Application Wizard–generated framework and the Event Handler Wizard.

In the next chapter, you’ll add the code necessary to draw elements in a view, and use the menus and toolbar buttons that you created here to select what to draw and in which color. This is where the Sketcher program begins to live up to its name.

EXERCISES
1. Add an Ellipse menu item to the Element menu.
2. Implement the command and command update handlers for the Ellipse menu item in the document class.
3. Add a toolbar button corresponding to the Ellipse menu item, and add status bar text and a tooltip for the button.
4. Modify the command update handlers for the color menu items so that the currently selected menu item displays in uppercase, and the others in lowercase.
WHAT YOU LEARNED ...

Get Ivor Horton's Beginning Visual C++ 2012 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.