唉,說來慚愧。記得在前面說過,打算在五一期間研究下PPC上怎么給程序換膚,結果計劃不如變化:拜見未來的岳父岳母花了3天,同學結婚花了一天。回來后,也沒啥心思搞了,不過大概還是知道些東西。要通過hook技術達到換膚的方法,還是比較困難地啊。好了,過去的不說了。不過,以后我有機會還是會繼續搞搞(現階段懂的還是少啊)。
現在切入正題:WTL 。什么是WTL?WTL 的全稱為 Windows Template Library, 是微軟ATL開發組成員Nenad Stefanovic先生在ATL Windowing機制上發展起來的一整套GUI框架。它運用模板(template)技術組織和創建GUI對象,構成了精制的面向對象框架,使面向對象與模板達成了精制的融合。
上面就是WTL的定義,準確地描述了什么是WTL。請注意我用紅色標記的兩個地方,那可以說是WTL的精髓。首先,WTL其實基于ATL的,它是ATL面向GUI編程的擴展;其次,WTL運用模板技術,這樣構建的程序精致短小。
需要指出的是WTL目前不被微軟官方支持也沒有開發文檔,不過能夠在其官方網站下到sdk。WTL貌似在民間非常受歡迎,用過的人都說好, 甚至有人說會超過MFC。現在最新版的WTL是8.0 beta2版,07年5月28日才發布的。
對比WTL和MFC,他們大部分是相通的。對于一個有過MFC編程經驗的人來說,熟悉WTL還是比較容易的。下面是他們的比較
Feature
| MFC
| WTL
|
Stand-alone library
| Yes
| No (built on ATL)
|
AppWizard support
| Yes
| Yes
|
ClassWizard support
| Yes
| No
|
Officially supported by Microsoft
| Yes
| No (Supported by volunteers inside MS)
|
Support for OLE Documents
| Yes
| No
|
Support for Views
| Yes
| Yes
|
Support for Documents
| Yes
| No
|
Basic Win32 & Common Control Wrappers
| Yes
| Yes
|
Advanced Common Control Wrappers (Flat scrollbar, IP Address, Pager Control, etc.)
| No
| Yes
|
Command Bar support (including bitmapped context menus)
| No (MFC does provide dialog bars)
| Yes
|
CString
| Yes
| Yes
|
GDI wrappers
| Yes
| Yes
|
Helper classes (CRect, Cpoint, etc.)
| Yes
| Yes
|
Property Sheets/Wizards
| Yes
| Yes
|
SDI, MDI support
| Yes
| Yes
|
Multi-SDI support
| No
| Yes
|
MRU Support
| Yes
| Yes
|
Docking Windows/Bars
| Yes
| No
|
Splitters
| Yes
| Yes
|
DDX
| Yes
| Yes (not as extensive as MFC)
|
Printing/Print Preview
| Yes
| Yes
|
Scrollable Views
| Yes
| Yes
|
Custom Draw/Owner Draw Wrapper
| No
| Yes
|
Message/Command Routing
| Yes
| Yes
|
Common Dialogs
| Yes
| Yes
|
HTML Views
| Yes
| Yes
|
Single Instance Applications
| No
| No
|
UI Updating
| Yes
| Yes
|
Template-based
| No
| Yes
|
Size of a statically linked do-nothing SDI application with toolbar, status bar, and menu
| 228KB + MSVCRT.DLL (288KB)
| 24k (with /OPT:NOWIN98) (+ MSVCRT.DLL if you use CString)
|
Size of a dynamically linked do-nothing SDI application with toolbar, status bar, and menu
| 24KB + MFC42.DLL (972KB) + MSVCRT.DLL (288KB)
| N/A
|
Runtime Dependencies
| CRT (+ MFC42.DLL, if dynamically linked)
| None (CRT if you use CString) |
聽說從WTL7.5開始支持PPC上編程,這可讓我大為開心。有機會試試用WTL在PPC上寫個程序。