Share via


Message Handlers

OverviewHow Do I

In MFC, a dedicated handler function processes each separate message. Message-handler functions are member functions of a class. This documentation uses the terms message-handler member function, message-handler function, message handler, and handler interchangeably. Some kinds of message handlers are also called “command handlers.”

Writing message handlers accounts for a large proportion of your work in writing a framework application. This article family describes how the message-processing mechanism works.

What does the handler for a message do? It does whatever you want done in response to that message. ClassWizard will create the handlers for you and allow you to implement them. You can jump directly from ClassWizard to the handler function’s definition in your source files and fill in the handler’s code using the Visual C++ source code editor. Or you can create all of your handlers with ClassWizard, then move to the editor to fill in all functions at once. For details on using ClassWizard, see How to Manage Commands and Messages with ClassWizard.

You can use all of the facilities of Microsoft Visual C++ and MFC to write your handlers. For a list of all classes, see in the Class Library Reference.