CMessageMap Class

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see CMessageMap Class on docs.microsoft.com. This class allows an object's message maps to be access by another object.

System_CAPS_ICON_important.jpg Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

class ATL_NO_VTABLE CMessageMap

Public Methods

NameDescription
CMessageMap::ProcessWindowMessageAccesses a message map in the CMessageMap-derived class.

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 ATL_NO_VTABLE CAtlEdit :
   OtherInheritedClasses
   public CComControl<CAtlEdit>
   // CComControl derives from CWindowImpl, which derives from CMessageMap
{
public:
   // Declare a contained window data member
   CContainedWindow m_ctlEdit;

   // 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. '1'
   //    identifies the alternate message map declared
   //    with ALT_MSG_MAP(1)
   CAtlEdit()
      : m_ctlEdit(_T("Edit"), this, 1)
   {
      m_bWindowOnly = TRUE;
   }

// Declare the default message map, identified by '0'
BEGIN_MSG_MAP(CAtlEdit)
   MESSAGE_HANDLER(WM_CREATE, OnCreate)
   MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
   CHAIN_MSG_MAP(CComControl<CAtlEdit>)
// Declare an alternate message map, identified by '1'
ALT_MSG_MAP(1)
   MESSAGE_HANDLER(WM_CHAR, OnChar)
END_MSG_MAP()

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

Accesses the message map identified by dwMsgMapID in a CMessageMap-derived class.

virtual BOOL ProcessWindowMessage(  
    HWND hWnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam,
    LRESULT& lResult,
    DWORD dwMsgMapID) = 0;

Parameters

hWnd
[in] The handle to the window receiving the message.

uMsg
[in] The message sent to the window.

wParam
[in] Additional message-specific information.

lParam
[in] Additional message-specific information.

lResult
[out] The result of the message processing.

dwMsgMapID
[in] The identifier of the message map that will process the message. The default message map, declared with BEGIN_MSG_MAP, is identified by 0. An alternate message map, declared with ALT_MSG_MAP(msgMapID), is identified by msgMapID.

Return Value

TRUE if the message is fully handled; otherwise, FALSE.

Remarks

Called by the window procedure of a CContainedWindow object or of an object that is dynamically chaining to the message map.

CDynamicChain Class
BEGIN_MSG_MAP
ALT_MSG_MAP
Class Overview

Show: