WTL中的消息映射

CHAIN_MSG_MAP_MEMBER

    BEGIN_MSG_MAP(CMainFrame)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        COMMAND_ID_HANDLER(ID_APP_EXIT, OnFileExit)
        COMMAND_ID_HANDLER(ID_VIEW_TOOLBAR, OnViewToolBar)
        COMMAND_ID_HANDLER(ID_VIEW_STATUS_BAR, OnViewStatusBar)
        COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
        COMMAND_ID_HANDLER_EX(IDC_CP_COLORS, OnCPColors)
        COMMAND_ID_HANDLER_EX(IDC_BW_COLORS, OnBWColors)
        COMMAND_ID_HANDLER_EX(IDC_START_STOP, OnStartStopClock)
        CHAIN_MSG_MAP(CUpdateUI)//将消息映射对应到这个父类中
        CHAIN_MSG_MAP(CFrameWindowImpl)
        CHAIN_MSG_MAP_MEMBER(m_view)//将消息映射映射到这个变量对应的消息映射中
    END_MSG_MAP()

 

 

COMMAND_ID_HANDLER vs COMMAND_ID_HANDLER_EX

COMMAND_ID_HANDLER对应的函数是

LRESULT OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

 

COMMAND_ID_HANDLER_EX对应的函数是

void OnCPColors ( UINT uCode, int nID, HWND hwncCtrl );

 

MESSAGE_HANDLER(WM_CREATE, OnCreate) vs MSG_WM_CREATE(OnCreate)

MESSAGE_HANDLER(WM_CREATE, OnCreate) 对应的函数是

LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

MSG_WM_CREATE(OnCreate)对应的函数是

LRESULT OnCreate(LPCREATESTRUCT lpcs),它需要在函数退出前调用SetMsgHandled函数

转载于:https://www.cnblogs.com/fanzi2009/archive/2009/07/26/1531630.html

你可能感兴趣的:(WTL中的消息映射)