090916(星期三) MFC訊息路由1

2021-05-05 05:08:03 字數 2161 閱讀 5347

一、命令路由

command routing 1

,增加乙個函式列表

類與訊息迴圈相關的函式

注意none

afxwndproc

global

none

afxcallwndproc

global

ccmdtarget

oncmdmsg

virtual

cdocument

oncmdmsg

virtual

cwnd

windowproc

virtual

oncommand

virtual

defwindowproc

virtual

cframewnd

oncommand

virtual

oncmdmsg

virtual

cview

oncmdmsg

virtual

2,全域性函式

afxwndproc

是推動引擎的起始點,在

mfc中的

cwinthread::run

中被呼叫,作為實驗,這裡在

main

函式中呼叫。

afxwndproc

在mfc

中有四個引數,這裡加上乙個表示誰獲得了訊息。

afxwndproc(0, wm_create, 0, 0, pmyframe);

表示pmyframe

獲得了乙個

wm_create

訊息。lresult afxwndproc(hwnd hwnd, uint nmsg, wparam wparam, lparam lparam,

cwnd *pwnd) // last param. pwnd is added by jjhou.

lresult afxcallwndproc(cwnd* pwnd, hwnd hwnd, uint nmsg,

wparam wparam, lparam lparam)

cwnd::windowproc

首先判斷訊息是否為

wm_command

,不是的話直接向父類推。每到乙個累的

messagemap

,原本都應該比較所處理訊息的陣列

(afx_msgmap_entry)

的每個元素,比較成功則進行處理。

lresult cwnd::windowproc(uint nmsg, wparam wparam, lparam lparam)

pmessagemap = getmessagemap();

for (; pmessagemap != null;

pmessagemap = pmessagemap->pbasemessagemap)

return 0; // j.j.hou: if find, should call lpentry->pfn,

// otherwise should call defwindowproc.

// for simplification, we just return 0. }

二、尋找

ctreectrl

處理雙擊事件的函式

1,類的聲名

#define declare_message_map()

private:

static const afx_msgmap_entry _messageentries;

protected:

static afx_data const afx_msgmap messagemap;

virtual const afx_msgmap* getmessagemap() const;

2,定義時的巨集

begin_message_map(ctreectrl, cwnd)

//}afx_msg_map

end_message_map()

#define on_wm_destroy()

,如此看來沒有加入雙擊事件的函式,是在基類裡面?

3 繼承圖

cobject

ccmdtarget

cwnd

ctreectrl 基類

cwnd

不可能做到樹形專案的展開啊。

明天繼續。

090909(星期三) 學習MFC二

一 乙個程序的生命週期1,shell 呼叫createprocess啟動 2,系統產生乙個進行核心物件 包括,semaphore file,process thread 3 系統為程序建立乙個位址空間 4,裝載 檔案指標 dll到程序位址空間 5,系統為程序建立乙個主線程 6,系統呼叫 starup...

2016 6 1 星期三 晴

前兩天聚會完那兩天,寫了一篇日誌發給盧老師。他說他很少關注別人的字型,但是我的字型卻很特別,說我的字這麼多年了也沒有變變。如果乙個同學記得你的字型,也是一件很開心的事情,更何況是每年要面對很多學生的老師,二十年過去了,一切依然是那麼如昨般深刻和親切。在我的心裡,他早就如親人般了。今天俊琦做了乙個騰雲...

2021 01 20 星期三 工作總結

工作 1 上午測試給前端的車輛任務發布介面和車輛狀態查詢介面。2 下午測試車端車輛任務狀態上報介面。發現乙個問題,netty啟動不起來,查了半下午沒頭緒,最後找了啟君,他說看了好久說是可能是handller裡不能直接注入cicv system中寫的service,注入的 ivehicletaskst...