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 ...

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