WTL for MFC Programmers(2)

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

Introduction to the Series

WTL rocks. It does. It has a lot of the power of MFC's GUI classes, yet produces substantially smaller executables. If you're like me, and learned GUI programming with MFC, you've become quite comfortable with all the control wrappers MFC provides, as well as with the flexible message handling built into MFC. If you're also like me and don't relish the idea of several hundred K of MFC framework getting added to your programs, WTL is for you. However, there are a few barriers we have to overcome:

 

    WTL有类似MFC那样的GUI类的功能,也能够产生足够小的可执行文件。如果你像我使用MFC来进行GUI编程,你已经非常习惯的使用MFC封装的控件,灵活的使用MFC提供的消息方式;如果你像我,不希望MFC数百K的框架程序随你的程序发布,那么WTL将适合你。然而,我们还须克服一些困难:

  • ATL-style templates look weird at first.
  • No ClassWizard support, so writing message maps involves some manual labor.
  • No documentation in MSDN, you need to find it somewhere else, or even look at the WTL source.
  • No reference books you can buy and keep on your shelf.
  • It has that "not officially supported by Microsoft" stigma
  • ATL/WTL windowing is sufficiently different from MFC windowing that not all your knowledge transfers over.
  • 首先,ATL风格的模板看起来是怪异的。
  • 没有类型向导的支持,所有的事件映射都需要手写。
  • 没有像MSDN那样的文档,经常需要参照WTL的源码。
  • 没有能够购买的参考书。
  • 微软不提供官方的支持。
  • ATL/WTL的窗体和MFC有着巨大的不同。

On the other hand, the benefits of WTL are:

另一方面,WTL的优点是:

  • No complex doc/view framework to learn or work around.
  • Has some essential UI features from MFC, like DDX/DDV and "update command UI" functionality.
  • Actually improves on some MFC features (e.g., more flexible splitter windows)
  • Much smaller executables compared to a statically-linked MFC app.
  • You can apply bug fixes to WTL yourself and not affect existing apps (compare this with replacing the MFC/CRT DLLs to fix a bug in one app, and having other apps break)
  • If you still need MFC, MFC and ATL/WTL windows can co-exist peacefully (for a prototype at work, I ended up creating an MFC CFrameWnd that contained a WTL CSplitterWindow, which contained MFC CDialogs -- that wasn't me showing off, it was modifying existing MFC code but using the nicer WTL splitter).
  • 没有复杂的文档/视图框架需要学习并在其上工作。
  • 提供MFC UI的本质特性,如DDX/DDVUI更新功能。
  • 实际上提高了MFC的某些特性,如更多变的分割窗体。
  • MFC静态连接更小的可执行文件。
  • 你可以自己在WTL中定位BUG,而不会影响已存在的项目(相对于在MFC/CRT DLL中定位BUG,会使其他程序中断)
  • 如果你仍然需要MFCATL/WTL可以和MFC混合使用(我曾经产生过一个MFCCFrameWnd,它设置一个包含MFC CDialog类的WTL CSplitterWindow类,通过这样做,我使用更漂亮的WTL分割器代替了MFC中已有的代码

In this series, I will first introduce the ATL windowing classes. WTL is, after all, a set of add-on classes to ATL, so a good understanding of ATL windowing is essential. Once I've covered that, I'll introduce WTL features and show how they make GUI programming a lot easier.

 

    在这个系列,我将首先介绍ATL的窗体类。由于WTL实际是一套ATL的扩展类,所以充分的了解ATL窗体类很重要。在此之后,我将介绍WTL的特性和如何使用他们来简化GUI编程。

Introduction to Part I

WTL rocks. But before we get to why, we need to cover ATL first. WTL is a set of add-on classes to ATL, and if you've been strictly an MFC programmer in the past, you may never have encountered the ATL GUI classes. So please bear with me if I don't get to WTL right off the bat; the detour into ATL is necessary.

 

    在我们了解WTL之前,我们需要先了解ATL。由于WTL是一套ATL的扩展类,而且如果你以前是一个完全的MFC程序员的话,你可能从没有接触过ATL GUI类。所以请原谅我没有直接讲述WTL,因为绕道ATL很重要。

 

In this first part, I will give a little background on ATL, cover some essential points you need to know before writing ATL code, quickly explain those funky ATL templates, and cover the basic ATL windowing classes.

在第一部分,我将给出一点ATL的知识,讲述一些在写ATL代码前你需要知道的基础要点,快速的说明那些让人心惊胆战的ATL模板,并揭示基本的ATL窗体类。

ATL Background

ATL and WTL history

The Active Template Library... kind of an odd name, isn't it? Old-timers might remember that it was originally the ActiveX Template Library, which is a more accurate name, since ATL's goal is to make writing COM objects and ActiveX controls easier. (ATL was also developed during the time that Microsoft was naming new products ActiveX-something, just as new products nowadays are called something.NET.) Since ATL is really about writing COM objects, it only has the most basic of GUI classes, the equivalent of MFC's CWnd and CDialog. Fortunately, the GUI classes are flexible enough to allow for something like WTL to be built on top of them.

 

     Active Template Library(活动模板库)似乎不像一个固定的名字,它的更确切的名字应该是ActiveX Templeate Library。最初是用来简化COMActiveX编程的(在ATL开发期间,微软的新产品叫作ActiveX,而现在这个产品叫作.NET)当ATL真正的应用在COM编程以后,他只提供了最基础的GUI类,就像MFCCWndCDialog。幸运的是,这些GUI的灵活性已经足够在其上建立像WTL这样的类库了。

 

WTL is currently in its second revision. The first was version 3.1, and the second is version 7. (The version numbers were chosen to match the ATL version numbers, that's why they're not 1 and 2.) Version 3.1 works with VC 6 and VC 7, although you need to define a couple of preprocessor symbols for VC 7. WTL version 7 is a drop-in replacement for version 3.1, and works without modification on VC 7, so there really is no reason to use 3.1 for new development.

   

    WTL的当前版本是他的第2个版本。第一个版本是3.1,第2个版本是7。(这个版本是跟随ATL的版本号定义的,并不是连续的)3.1版可以工作在VC6VC7上,不过需要为VC7定义一对预处理程序标识。WTL 7版在3.1版基础上进行了提升,在VC7上部需要作任何改动,所以没有任何理由再使用3.1版开发新的程序了。

(现在WTL的最新版为7.1 --- 蜗牛手记)

VC++环境下XML操作的完整指南 可扩展标记语言(XML)作为一种数据交换格式,已被广泛应用于网络数据传输和存储。XML通过使用一系列规则和结构来描述数据,确保不同系统间的数据交换保持一致性和准确性。XML是一种标记语言,用于存储和传输数据,但与HTML不同,它不是为了显示数据,而是为了描述数据。它允许用户创建自己的标签,定义自己的数据类型,从而让数据的结构和内容具有自解释性。DOM(文档对象模型)是将文档以树形结构呈现的编程接口,它定义了文档的逻辑结构和如何通过编程语言去访问文档结构。 阅读详情

相关推荐

WTL for MFC Programmers 中英文:深入掌握轻量级Windows开发

Windows Template LibraryWTL)是一个轻量级的C++库,用于简化Windows应用程序的开发。它不提供完整的应用程序框架,而是专注于提供一组灵活的工具,用于构建窗口、控件以及与之交互的代码。WTL的设计目标是为开发者提供快速开发小型到中型Windows应用程序的能力,同时保持对应用程序大小和性能的控制。虽然WTL提供了大量预定义的控件类,但有时可能需要根据特定需求创建自定义控件。自定义控件类的开发涉及继承WTL的窗口类模板并实现特定的接口。

weixin_32925455的博客 1302

WTL For MFC Programmer(中文版)

WTL For MFC Programmer(中文版).pdf

WTL for MFC Programmers

这是为MFC开发者阅读的WTL类库. WTL (Windows Template Library) 是建立在 ATL 的, 功能类似 MFC 的UI 库, 用于开发有 UI 界面的 Windows 程序. WTL 不像 MFC 那样建立一张庞大的 虚函数表, 所以生成的程序非常小, 并且不依赖于庞大的MFC 运行库.

模仿qq界面实现(WTL

前面对于界面用哪一种我试过用duilib,但是老感觉和MFC差距有点多,终于发现WTL的库能够实现我的所有界面功能,几天的努力终于搞定界面的重写。还是见我的成果吧: 1登录界面: 2主界面: 3.主界面的下拉菜单 4.托盘: 5.聊天主界面: 6.服务器后台基本不变(但是增加对多字节的处理) 唉,说句感慨,互联网+、大数据和物联网让java开发越来越...

daru9708的博客 156

WTL for MFC Programmers, Part II - WTL GUI Base Classes

WTL for MFC Programmers, Part II - WTL GUI Base Classes原作 :Michael Dunn [英文原文]翻译 :Orbit(星轨 oRbIt) [http://www.winmsg.com/cn/orbit.htm] 输入您的搜索字词

oRbIt 的专栏 3364

WTL for MFC Programmers(1)

WTL for MFC ProgrammersMFCWTL 原著 Michael Dunn 编译 蜗牛手记译前序       一直以来都是在MFC的平台上开发,忽然有一天开发的东西需要跨入没有MFC的平台上才发现Window编程和MFC编程的区别,如何能够快速的由MFC转入WINDOW平台呢,找来找去发现了WTL这个奇怪的东西。       说它奇怪,一点也不过分,

蜗牛档案室 2903

WTL for MFC Programmers, Part VII - Splitter Windows

WTL for MFC Programmers, Part VII - Splitter Windows原作 :Michael Dunn [英文原文]翻译 :Orbit(星轨 oRbIt) [http://www.winmsg.com/cn/orbit.htm]下载演示程序代码本章内容 介绍 WTL 的分隔窗口 相关的类

oRbIt 的专栏 2980

WTL for MFC Programmers, Part VI - Hosting ActiveX Controls

WTL for MFC Programmers, Part VI - Hosting ActiveX Controls原作 :Michael Dunn [英文原文]翻译 :Orbit(星轨 oRbIt) [http://www.winmsg.com/cn/orbit.htm]下载演示程序代码本章内容 介绍 从使用向导开始 建立工程

oRbIt 的专栏 4455

WTL for MFC Programmers 中英文

WTL for MFC Programmers 中英文

WTL for MFC Programmers(中文版)

这个资源在网上很多下得到,只不过是html文件包,不方便使用,这个是我做的一个chm文件,希望对大家有用。

编写WTL资料《WTL for MFC Programmers

这个就是大名鼎鼎的(也是唯一的)WTL编程书籍《WTL for MFC Programmers》。

WTL for MFC Programmers, Part VIII - Property Sheets and Wizards

WTL for MFC Programmers, Part VIII - Property Sheets and Wizards原作 :Michael Dunn [英文原文]翻译 :Orbit(星轨 oRbIt) [http://www.winmsg.com/cn/orbit.htm]

oRbIt 的专栏 3010

WTL for MFC Programmers, Part I - ATL GUI Classes

README.TXT 在你开始使用WTL或着在本文章的讨论区张贴消息之前,我想请你先阅读下面的材料。 你需要开发平台SDK(Platform SDK)。你要使用WTL不能没有它,你可以使用在线升级安装开发平台SDK,也可以下载全部文件后在本地安装。在使用之前要将SDK的包含文件(.h头文件)和库文件(.Lib文件)路径添加到VC的搜索目录,SDK有现成的工具完成这个工作,这个工具位于开

zcxin的专栏 1609

WTL for MFC Programmers,Part IV - Dialogs and Controls

对第四章的介绍 MFC 的对话框和控件的封装真得可以节省你很多时间和功夫。没有MFC对控件的封装,你要操作控件就得耐着性子填写各种结构并写很多的SendMessage调用。MFC还提供了对话框数据交换(DDX),它可以在控件和变量之间传输数据。WTL 当然也提供了这些功能,并对控件的封装做了很多改进。本文将着眼于一个基于对话框的程序演示你以前用MFC实现的功能,除此之外还有WTL消息处理的增

zcxin的专栏 1164

WTL for MFC Programmers, 中文版序言

WTL for MFC Programmers, Chinese Version Prologue 我一直在寻找这样一个类库:他对Windows的窗口提供面向对象的封装,有灵活的消息响应机制和比较完备的界面框架解决方案,对标准控件提供简练实用的封装,支持操作系统的新特性,支持功能扩充和二次开发,有代码自动生成向导机制,生成的程序使用较少的系统资源,最后是有完全的代码支持和文档支持。你会

oRbIt 的专栏 4033

WTL for MFC Programmers(5)

Defining a Window Implementation定义一个窗体实现Any non-dialog window you create will derive from CWindowImpl. Your new class needs to contain three things:你所产生的任何非对话框的窗体都将从CWindowImpl派生,你需要为你的新类做下面的3件事

蜗牛档案室 1455

WTL for MFC Programmers, Chinese Version Prologue

我一直在寻找这样一个类库:他对Windows的窗口提供面向对象的封装,有灵活的消息响应机制和比较完备的界面框架解决方案,对标准控件提供简练实用的封装,支持操作系统的新特性,支持功能扩充和二次开发,有代码自动生成向导机制,生成的程序使用较少的系统资源,最后是有完全的代码支持和文档支持。 你会说那就用MFC吧! 是的,我一直使用MFC,但我对MFC已经越来越厌倦了。陈旧的类库使得它无法支持

zcxin的专栏 942
上一篇: WTL for MFC Programmers(1)
下一篇: [原创] WTL for MFC Programming实践篇 --- 一个自定义ComboBox的移植过程(上)
snaill
博客等级 码龄27年 599粉丝 159原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值