WTL for MFC Programmers(1)

WTL for MFC Programmers

MFCWTL

 

原著 Michael Dunn

编译 蜗牛手记


译前序

       一直以来都是在MFC的平台上开发,忽然有一天开发的东西需要跨入没有MFC的平台上才发现Window编程和MFC编程的区别,如何能够快速的由MFC转入WINDOW平台呢,找来找去发现了WTL这个奇怪的东西。

       说它奇怪,一点也不过分,微软开发的开放原码的东西,没有官方的任何资源,版本也怪,第一版是3.1,都说微软的东西要到3.0以后才能用,windows是,IE是,window ce也是,难道为了说明自己第一版就能用,所以直接就着这么定义了?当然是开玩笑,至于为什么,文中自有答案。

       本文原文刊登在http://www.codeproject.com,通读以后觉得行文稍显啰嗦,但是一步一步的讲解的非常清楚易懂,很多地方还和MFC相互例证,使读者在学习WTL的同时了解MFC的运行情况。

       由于本人水平有限,所以采用英汉对应的方法,便于读者在发现中文行文问题时对照原文理解。

 

 

                                                                                                  蜗牛手记

                                                                                           http://www.chinaos.com


关于作者Michael Dunn

 Michael lives in sunny Los Angeles , California , and is so spoiled by the weather that he will probably never be able to live anywhere else. He started programming with an Apple //e in 4th grade, graduated from UCLA with a math degree in 1995, and immediately landed a job as a QA engineer at Symantec, working on the Norton AntiVirus team. He pretty much taught himself Windows and MFC programming, and in 1999 he designed and coded a new interface for Norton AntiVirus 2000.

    Mike now works as a developer at Napster, an online subscription music service. He also developed UltraBar, an IE toolbar plugin that makes web searching easy and trounces the Google toolbar; the CodeProject SearchBar; and has co-founded Zabersoft, a development company with offices in Los Angeles and Odense , Denmark .

    He also enjoys his hobbies of playing pinball, bike riding, and the occasional PlayStation, Dreamcast, or MAME game. He is also sad that he's forgotten the languages he's studied: French, Mandarin Chinese, and Japanese.

 

Part I - ATL GUI Classes

第一章 ATLGUI

 

An introduction to WTL programming for MFC developers 

一个适用于MFC程序员的WTL入门

README.TXT

阅读须知

This is the stuff I want you to read first, before proceeding on or posting messages to this article's discussion board.

我希望你在开始阅读或讨论这篇文章之前,能先读以下的信息。

You need the Platform SDK. You can't use WTL without it. You can use the online SDK Update site, or download the CAB files and run the setup locally. Be sure you use the utility to add the SDK include and lib directories to the VC search path. You can find this in the Visual Studio Registration folder in the Platform SDK program group.

你需要Platform SDK,没有它WTL无法运行。你可以在线使用SDK Update网站,或者下载cab文件到本地安装。请确定你在VC的搜索路径中添加了有效的SDKincludelib路径。你可以在Platform SDK的程序组的Visual Studio Registration中找到这些路径的信息。

You need WTL. Download version 7 from Microsoft. See the articles "Introduction to WTL - Part 1" and "Easy installation of WTL" for some tips on installing the files. Those articles are rather out-of-date now, but still contain some good info. One thing which I don't think is mentioned in those articles is how to tell VC to search the WTL include directory. In VC 6, click Tools|Options and go to the Directories tab. In the Show directories for combo box, select Include files. Then add a new entry that points to the directory where you put the WTL header files.

你需要WTL。从微软的网站下载WTL 7。阅读文章本文后面的部分来安装这些文件。然后你需要在VC的搜索路径中添加WTLinclude目录。在VC6中,点击菜单项Tools|Options,然后寻找Directories页。在标签为Show directories for:的组合框中选择Include files。然后添加WTL头文件路径到下面的列表中。

You need to know MFC, and know it well enough that you understand what's behind the message map macros, and can edit the code marked "DO NOT EDIT" with no problems.

你需要了解MFC的消息宏的运作方式,还应该能够编辑被标注了“DO NOT EDIT”的代码。

You need to know Win32 API programming, and know it well. If you learned Windows programming by going straight into MFC, without learning how messages work at the API level, you are unfortunately going to have trouble in WTL. If you don't know what a message's WPARAM and LPARAM mean, you should read other articles (there are lots of them here at CodeProject) so you understand.

你需要了解一些Win32 API编程的知识,如果你只学习MFC来进行Windows编程,而不了解API级别的消息处理机制,很不幸,你在学习WTL的进程中将遇到不少麻烦。如果你不知道消息中WPARMLPARAM的含义,你需要一起其他的相关的资料作为参考。

You need to know C++ template syntax. See the VC Forum FAQ for links to C++ FAQs and template FAQs.

你需要知道c++模板的语法。访问http://www.codeproject.com/cpp/cppforumfaq.asp#other_cpp                  去了解更多的关于这方面的知识。

I will only be covering VC 6 features, but as far as I know everything should work on VC 7. Since I don't use VC 7, I won't be able to help with VC 7 problems. However, feel free to post VC 7 questions, as other readers might be able to help.

我将只讲述VC6相关的特性,虽然我知道在不远的将来所有的工作将在VC7上进行,但是我还没有使用VC7,所以无法提供相关的帮助。然而,你也可以贴出VC7相关的问题,也许其他的读者能够提供帮助。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
WTL 具有两面性,确实是这样的。它没有MFC的界面(GUI)类库那样功能强大,但是能够生成很小的可执行文件。如果你象我一样使用MFC进行界面编程,你会觉得MFC提供的界面控件封装使用起来非常舒服,更不用说MFC内置的消息处理机制。当然,如果你也象我一样不希望自己的程序仅仅因为使用了MFC的框架就增加几百K的大小的话,WTL就是你的选择。当然,我们还要克服一些障碍: ATL样式的模板类初看起来有点怪异 没有类向导的支持,所以要手工处理所有的消息映射。 MSDN没有正式的文档支持,你需要到处去收集有关的文档,甚至是查看WTL的源代码。 买不到参考书籍 没有微软的官方支持 ATL/WTL的窗口与MFC的窗口有很大的不同,你所了解的有关MFC的知识并不全部适用与WTL。 从另一方面讲,WTL也有它自身的优势: 不需要学习或掌握复杂的文档/视图框架。 具有MFC的基本的界面特色,比如DDX/DDV和命令状态的自动更新功能(译者加:比如菜单的Check标记和Enable标记)。 增强了一些MFC的特性(比如更加易用的分隔窗口)。 可生成比静态链接的MFC程序更小的可执行文件(译者加:WTL的所有源代码都是静态链接到你的程序中的)。 你可以修正自己使用的WTL中的错误(BUG)而不会影响其他的应用程序(相比之下,如果你修正了有BUG的MFC/CRT动态库就可能会引起其它应用程序的崩溃。 如果你仍然需要使用MFCMFC的窗口和ATL/WTL的窗口可以“和平共处”。(例如我工作中的一个原型就使用了了MFC的CFrameWnd,并在其内包含了WTL的CSplitterWindow,在CSplitterWindow中又使用了MFC的CDialogs -- 我并不是为了炫耀什么,只是修改了MFC的代码使之能够使用WTL的分割窗口,它比MFC的分割窗口好的多)。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值