唉,说来惭愧。记得在前面说过,打算在五一期间研究下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上写个程序。