共用方式為


CMessageMap 類別

這個類別可讓另一個物件存取物件的訊息對應。

重要

這個類別及其成員不能用於在Windows 執行階段中執行的應用程式。

語法

class ATL_NO_VTABLE CMessageMap

成員

公用方法

名稱 描述
CMessageMap::P rocessWindowMessage 存取衍生類別中的 CMessageMap 訊息對應。

備註

CMessageMap 是抽象基類,可讓另一個物件存取物件的訊息對應。 為了讓物件公開其訊息對應,其類別必須衍生自 CMessageMap

ATL 使用 CMessageMap 來支援自主視窗和動態訊息對應鏈結。 例如,任何包含 CContainedWindow 物件的類別都必須衍生自 CMessageMap 。 下列程式碼取自 SUBEDIT 範例。 透過 CComControl ,類別 CAtlEdit 會自動衍生自 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 使用包含類別中的訊息對應, CAtlEdit 衍生自 CMessageMap

如需訊息對應的詳細資訊,請參閱 一文中的訊息地圖

需求

標頭: atlwin.h

CMessageMap::P rocessWindowMessage

存取衍生類別中 CMessageMap dwMsgMapID 識別的訊息對應。

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

參數

hWnd
[in]接收訊息之視窗的控制碼。

uMsg
[in]傳送至視窗的訊息。

wParam
[in]其他訊息特定資訊。

lParam
[in]其他訊息特定資訊。

lResult
[out]訊息處理的結果。

dwMsgMapID
[in]將處理訊息之訊息對應的識別碼。 使用 BEGIN_MSG_MAP 宣告的預設訊息對應會以 0 來識別。 以 ALT_MSG_MAP(msgMapID) 宣告 的替代訊息對應是由 識別 msgMapID

傳回值

如果訊息已完全處理,則為 TRUE;否則為 FALSE。

備註

由 CContainedWindow 物件的視窗程式 或動態鏈結至訊息對應的物件呼叫。

另請參閱

CDynamicChain 類別
BEGIN_MSG_MAP
ALT_MSG_MAP(msgMapID)
類別概觀