MFC的消息流動

MFC的消息流動

本文分析MFC4.0的消息流動,從註冊消息處理函數到窗口接受到消息的處理過程;

MFC中MessageMap用到的數據類型

struct AFX_MSGMAP
{
    AFX_MSGMAP* pBaseMessageMap;
    AFX_MSGMAP_ENTRY* lpEntries;
};
struct AFX_MSGMAP_ENTRY // MFC 4.0 format
{
    UINT nMessage; // windows message
    UINT nCode; // control code or WM_NOTIFY code
    UINT nID; // control ID (or 0 for windows messages)
    UINT nLastID; // used for entries specifying a range of control id's
    UINT nSig; // signature type (action) or pointer to message #
    AFX_PMSG pfn; // routine to call (or special value)
};

基於Docment/View的窗口處理函數創建過程

最終只要是基於CWnd的類都將自己的窗口函數註冊爲AfxWndProc,註冊過程如下
1.CWnd::CreateEx
2. AfxHookWindowCreate
3. AfxHookWindowCreate
4. _AfxCbtFilterHook
5. _AfxStandardSubclass((HWND)wParam)
6. AfxGetAfxWndProc()
7. AfxWndProc
消息流動如下
這裏寫圖片描述

發佈了36 篇原創文章 · 獲贊 21 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章