We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

Event Maps

Whenever a control wishes to notify its container that some action (determined by the control developer) has happened (such as a keystroke, mouse click, or a change to the control's state) it calls an event-firing function. This function notifies the control container that some important action has occurred by firing the related event.

The Microsoft Foundation Class Library offers a programming model optimized for firing events. In this model, "event maps" are used to designate which functions fire which events for a particular control. Event maps contain one macro for each event. For example, an event map that fires a stock Click event might look like this:


The EVENT_STOCK_CLICK macro indicates that the control will fire a stock Click event every time it detects a mouse click. For a more detailed listing of other stock events, see the article ActiveX Controls: Events. Macros are also available to indicate custom events.

Although event-map macros are important, you generally do not insert them directly. This is because the Properties window automatically creates event-map entries in your source files when you use it to associate event-firing functions with events. Any time you want to edit or add an event-map entry, you can use the Properties window.

To support event maps, MFC provides the following macros:

Event Map Declaration and Demarcation


Declares that an event map will be used in a class to map events to event-firing functions (must be used in the class declaration).


Begins the definition of an event map (must be used in the class implementation).


Ends the definition of an event map (must be used in the class implementation).

Event Mapping Macros


Indicates which event-firing function will fire the specified event.


Indicates which event-firing function will fire the specified event, with a designated dispatch ID.

Message Mapping Macros


Indicates a custom verb handled by the OLE control.


Overrides a standard verb mapping of the OLE control.