O'Reilly logo

Ivor Horton's Beginning Visual C++ 2013 by Ivor Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 13Working with Menus and Toolbars

  • How an MFC-based program handles messages
  • How you create and modify menu resources
  • How you create and modify menu properties
  • How to create functions to service menu messages
  • How to add handlers to update menu properties
  • How to add toolbar buttons associated with menu items

You can find the wrox.com code downloads for this chapter on the Download Code tab at www.wrox.com/go/beginningvisualc. The code is in the Chapter 13 download and individually named according to the names throughout the chapter.

COMMUNICATING WITH WINDOWS

Windows communicates with your program by sending messages to it. Most of the drudgery of message handling is taken care of in an MFC application, so you don’t have to worry about providing a WndProc() function. The 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. In an MFC-based program, a message handler is always a member of one of your application’s classes.

The association between a particular message and a function in your program that is to service it is established by a message map, and each class in your program that handles Windows messages will have one. A message map is a table of member functions that handle messages bounded by a couple of macros. The start of a message map is indicated ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required