Share via


CMessageMap クラス

このクラスでは、オブジェクトのメッセージ マップに別のオブジェクトからアクセスできます。

class ATL_NO_VTABLE CMessageMap

解説

CMessageMap は抽象基本クラスであり、オブジェクトのメッセージ マップに別のオブジェクトからアクセスできます。 オブジェクトのメッセージ マップを公開するには、CMessageMap の派生クラスを作成する必要があります。

ATL では、子ウィンドウおよびメッセージ マップの動的チェインという 2 つの機能を CMessageMap を使ってサポートします。 たとえば、CContainedWindow オブジェクトをクラスに含めるには、このクラスを CMessageMap から派生して作成する必要があります。 SUBEDIT サンプルのコードを次に示します。 この例の中で、CAtlEdit クラスは CComControl を通して 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()

子ウィンドウ m_EditCtrl はコンテナー クラスのメッセージ マップを使うので、CMessageMap から CAtlEdit が派生します。

メッセージ マップの詳細については、「ATL ウィンドウ クラス」の「メッセージ マップ」を参照してください。

必要条件

**ヘッダー:**atlwin.h

参照

参照

CDynamicChain クラス

BEGIN_MSG_MAP

ALT_MSG_MAP

その他の技術情報

CMessageMap のメンバー

ATL クラスの概要