WTL實踐經驗總結 不斷更新

2021-05-17 18:31:58 字數 2869 閱讀 7970

一.wtl的使用

二.wtl的結構

三.wtl的剖析

四.wtl的資源

五.wtl的專案(我自己寫的哦)

選擇wtl很大部分原因都是因為對模板的迷戀,不知為啥,c++的魅力盡然在模板!好,開始我們的征程吧。

一 wtl的使用

1.安裝:網上已經很多這樣的文章了,看這裡,這裡

2.幫助外掛程式:visualfc、wtlhelper

3.教程:

二 wtl的結構

wtl的類大致分為:

1.框架視窗:cframewindowimpl、cmdiframewindowimpl

2.控制項封裝: cbuttont、clistviewctrl

3.gdi封裝: cdct、cmenut

4.特殊介面封裝:csplitterwindow、cupdateui、ccustomdraw

5.實用工具類:cstring、crect

6.巨集:begin_msg_map、end_msg_map

先來看看令人頭疼的「巨集」介紹吧:

1.在atlcrack.h中,begin_msg_map_ex和end_msg_map_ex用來處理視窗訊息的派發

// note about message maps with cracked handlers:

2:

// for atl 3.0, a message map using cracked handlers must use begin_msg_map_ex.

3:

// for atl 7.0 or higher, you can use begin_msg_map for cwindowimpl/cdialogimpl derived classes,

4:

// but must use begin_msg_map_ex for classes that don't derive from cwindowimpl/cdialogimpl.

5:
6:

#define begin_msg_map_ex(theclass) /

7:

public: /

8:

/* 在ui類中,宣告乙個m_bmsghandled的變數,來判斷訊息是否已處理,是否需要傳給基類*/ /

9:     bool m_bmsghandled; /
10:

/* "handled" management for cracked handlers */ /

11:     bool ismsghandled() const /
12:      /
15:

void setmsghandled(bool bhandled) /

16:      /
19:     bool processwindowmessage(hwnd hwnd, uint umsg, wparam wparam, lparam lparam, lresult& lresult, dword dwmsgmapid = 0) /
20:      /
26:

/* 帶下劃線開頭的函式,都是本類才呼叫的函式,一般做法為宣告在private區域中*/ /

27:     bool _processwindowmessage(hwnd hwnd, uint umsg, wparam wparam, lparam lparam, lresult& lresult, dword dwmsgmapid) /
28:      /
8:

return

false; /

9:     }
10:
11:

#define end_msg_map_ex end_msg_map

看,乙個switch結構就在_processwindowmessage中就完成了。而其他的訊息巨集不過就是根據訊息裡wparam、lparam的不同意義封裝不同的引數麼?來看幾個典型代表

///

2:

// standard windows message macros

3:
4:

// int oncreate(lpcreatestruct lpcreatestruct)

5:

#define msg_wm_create(func) /

6:

if (umsg == wm_create) /

7:
13:
14:

// bool oninitdialog(cwindow wndfocus, lparam linitparam)

15:

#define msg_wm_initdialog(func) /

16:

if (umsg == wm_initdialog) /

17:

是吧,沒錯!訊息的crack而已。

使用wtl::cstring前定義_wtl_user_cstring

使用setmsghandle(false)讓訊息流入基類

atl的cwindow類只有乙個資料成員,沒有mfc視窗中的物件鏈.當乙個cwindow類超出作用域時,它關聯的視窗並不銷毀掉。

atl中的視窗過程是cwindowimpl.cdialogimpl實現普通對話方塊的視窗過程、caxdialogimpl實現activex對話方塊

三 wtl的剖析

四 wtl的資源

1.論壇: yahoo

2.article: codeproject、viksoe

五 wtl的專案

專案實踐經驗總結 (1)

media screen and min width 768px media screen and min width 992px media screen and min width 1200 注意下順序,如果你把 media min width 768px 寫在了下面那麼很悲劇,media sc...

kafka相關實踐 經驗總結

kafka快的原因 1 partition順序讀寫,會先寫入頁快取,再寫入磁碟,充分利用磁碟特性,這是基礎 2 producer生產的資料持久化到broker,採用mmap檔案對映,實現順序的快速寫入 3 頁快取技術在讀取時可以實現零拷貝,減少io,加快socket傳輸速度 4 customer從b...

mysql學習經驗與總結不斷更新中

mysql首先選擇的是.zip版本的 然後,解壓到任意的檔案下面 解壓後在環境變數path下加入mysqlserver bin的路徑 這個時候仍然不能啟動mysql還需要在 mysql資料夾下找到my.ini或my default.ini檔案 然後開啟檔案修改以下變數 mysqld basedir ...