CMessageMap Class
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

CMessageMap Class 

This class allows an object's message maps to be access by another object.

class ATL_NO_VTABLE CMessageMap

CMessageMap is an abstract base class that allows an object's message maps to be accessed by another object. In order for an object to expose its message maps, its class must derive from CMessageMap.

ATL uses CMessageMap to support contained windows and dynamic message map chaining. For example, any class containing a CContainedWindow object must derive from CMessageMap. The following code is taken from the SUBEDIT sample. Through CComControl, the CAtlEdit class automatically derives from CMessageMap.

class CAtlEdit : public CComControl<CAtlEdit>, ...
               // CComControl derives from CWindowImpl,
               // which derives from CMessageMap
   // Declare a contained window data member
   CContainedWindow m_EditCtrl;

   // Initialize the contained window:
   // 1. Pass "EDIT" to specify that the contained 
   //    window should be based on the standard 
   //    Windows Edit box
   // 2. Pass 'this' pointer to specify that CAtlEdit 
   //    contains the message map to be used for the 
   //    contained window's message processing
   // 3. Pass the identifier of the message map. In
   //    this case, '1' identifies the message map
   //    declared with ALT_MSG_MAP(1)
   CAtlEdit() : m_EditCtrl(_T("EDIT"), this, 1)
      m_bWindowOnly = TRUE;

   // Declare the default message map
   // Declare an alternate message map,
   // identified by '1'


Because the contained window, m_EditCtrl, will use a message map in the containing class, CAtlEdit derives from CMessageMap.

For more information about message maps, see Message Maps in the article "ATL Window Classes."

Header: atlwin.h

© 2016 Microsoft