Message Map Macros (MFC)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Message Map Macros (MFC).

To support message maps, MFC supplies the following macros:

Message-Map Declaration and Demarcation Macros

DECLARE_MESSAGE_MAPDeclares that a message map will be used in a class to map messages to functions (must be used in the class declaration).
BEGIN_MESSAGE_MAPBegins the definition of a message map (must be used in the class implementation).
END_MESSAGE_MAPEnds the definition of a message map (must be used in the class implementation).

Message-Mapping Macros

ON_COMMANDIndicates which function will handle a specified command message.
ON_CONTROLIndicates which function will handle a specified control-notification message.
ON_MESSAGEIndicates which function will handle a user-defined message.
ON_OLECMDIndicates which function will handle a menu command from a DocObject or its container.
ON_REGISTERED_MESSAGEIndicates which function will handle a registered user-defined message.
ON_REGISTERED_THREAD_MESSAGEIndicates which function will handle a registered user-defined message when you have a CWinThread class.
ON_THREAD_MESSAGEIndicates which function will handle a user-defined message when you have a CWinThread class.
ON_UPDATE_COMMAND_UIIndicates which function will handle a specified user-interface update command message.

Message-Map Range Macros

ON_COMMAND_RANGEIndicates which function will handle the range of command IDs specified in the first two parameters to the macro.
ON_UPDATE_COMMAND_UI_RANGEIndicates which update handler will handle the range of command IDs specified in the first two parameters to the macro.
ON_CONTROL_RANGEIndicates which function will handle notifications from the range of control IDs specified in the second and third parameters to the macro. The first parameter is a control-notification message, such as BN_CLICKED.

For more information on message maps, the message-map declaration and demarcation macros, and the message-mapping macros, see Message Maps and Message Handling and Mapping Topics. For more information about message-map ranges, see Handlers for Message-Map Ranges.

Message Maps

Show: