`

Windows Template Library (WTL)相关资料学习

    博客分类:
  • C++
阅读更多

 

初识 WTL( )
作者: orange

 

下载本文示例工程

 

 

1 .前言

 

虽然 MFC 的功能很强大,但 Windows Template Library(WTL) 的出现,无疑说明了 MFC 有一定的弊病。和 MFC 相比,功能并没有 MFC 完善。比如 MFC 支持 doc/view 架构,而 WTL 不支持。同时, WTL 也没有 Microsoft 的官方支持。但是, WTL 是基于模版 (template) 的,其应用程序最小只有 24KB ,同时不象 MFC ,依赖 DLL 。但是 WTL 也实现了 CString CRect CSize CPoint 等常用的类,还 CStaticT<TBase> CButtonT<TBase> CListBoxT<TBase> CComboBoxT<TBase>( 这些在 WTL 库文件 atlctrls.h atlctrlw.h atlctrlx.h 中就能看到 ) 用起来和 MFC 版本也没太大不同。

 

2 .准备工作

 

首先安装 WTL AppWizard, 现在最高版本应该是 WTL7.0, 直接运行 setup 脚本文件就可以了 , 这里给大家几个下载地址 :

 

1) http://www.vckbase.com/tools/listtools.asp?tclsid=111

 

2)http://www.microsoft.com/downloads/details.aspx?familyid=128e26ee-2112-4cf7-b28e-7727d9a1f288&displaylang=en

 

3) http://www.copathway.com/vchelp/zsrc/wtlm.asp?type_id=70&class_id=1&cata_id=3&article_id=374

 

这样当你启动 VC6.0 后, File/New 时,在 Project 属性页就能看到添加了一项 ATL/WTL AppWizard 。你可以直接把 WTL 的库文件 ( 16 .h 文件 ) 拷贝到 vc 的安装目录 VC98/Include 中,也可以放到你的工程文件夹中。

 

3 .应用实例 1---SDI 中状态栏的应用

 

(1) File/New, 如图:

 

<!--[if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" alt="" style='width:431.25pt;height:317.25pt'> <v:imagedata src="file:///C:\DOCUME~1\JACKY_~1\LOCALS~1\Temp\msohtml1\01\clip_image002.gif" o:href="http://www.vckbase.com/document/journal/vckbase22/images/TestWTL2.gif"/> </v:shape><![endif]--><!--[if !vml]--> <!--[endif]-->

 

(2) OK 后,

 

SDI(Single Document Interface) 应用程序通常只有一个主窗口 ( 通常是一个框架窗口, Frame Window) 。框架窗口包含菜单、工具栏、状态栏和称为视 (View) 的客户工作区。

 

Multip-SDI(Multiple Threads SDI) ,就像 IE 浏览器,使用 " 文件 / 新建 / 窗口 " 命令后,会出现另一个 IE 窗口。

 

MDI(Multiple Document Interface) 应用程序有一个主框架窗口,但有多个子框架窗口。每个子窗口都有自己的视 (View), MFC 的相似。

 

Dialog 应用程序是基于对话框的。

 

<!--[if gte vml 1]><v:shape id="_x0000_i1027" type="#_x0000_t75" alt="" style='width:378pt;height:280.5pt'> <v:imagedata src="file:///C:\DOCUME~1\JACKY_~1\LOCALS~1\Temp\msohtml1\01\clip_image003.png" o:href="http://www.vckbase.com/document/journal/vckbase22/images/TestWTL3.gif"/> </v:shape><![endif]--><!--[if !vml]--> <!--[endif]-->

 

(3) Next

 

<!--[if gte vml 1]><v:shape id="_x0000_i1028" type="#_x0000_t75" alt="" style='width:378pt;height:4in'> <v:imagedata src="file:///C:\DOCUME~1\JACKY_~1\LOCALS~1\Temp\msohtml1\01\clip_image005.png" o:href="http://www.vckbase.com/document/journal/vckbase22/images/TestWTL4.gif"/> </v:shape><![endif]--><!--[if !vml]--> <!--[endif]-->

 

(4) 在产生的文件中可以看到 WTL 确实不支持 Doc/View.

 

WTL 对单界面线程的封装: WTL 使用一个 _Module 全局变量来保存全局数据,并通过它来引用应用程序级的代码。在 WTL 中,该变量是 CAppModule 的实例,想象 MFC theApp

 

下面对 MyTestWTL.cpp 文件中的函数作一些说明:

 

 

int WINAPI _tWinMain ( HINSTANCE hInstance , HINSTANCE /*hPrevInstance*/ , LPTSTR lpstrCmdLine , int nCmdShow )

 

{

 

HRESULT hRes = :: CoInitialize ( NULL );

 

// If you are running on NT 4.0 or higher you can use the following call instead to

 

// make the EXE free threaded. This means that calls come in on a random RPC thread.

 

// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);

 

 

ATLASSERT ( SUCCEEDED ( hRes ));

 

 

// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used

 

:: DefWindowProc ( NULL , 0 , 0 , <chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="0" unitname="l" w:st="on"><span style="color: purple;">0L</span></chmetcnv>);

 

AtlInitCommonControls ( ICC_COOL_CLASSES | ICC_BAR_CLASSES ); // add flags to support other controls

 

hRes = _Module . Init ( NULL , hInstance );

 

ATLASSERT ( SUCCEEDED ( hRes ));

 

int nRet = Run ( lpstrCmdLine , nCmdShow ); // 程序逻辑,调用全局函数 Run()

 

_Module . Term (); // 终止模块

 

 

:: CoUninitialize ();

 

 

分享到:
评论

相关推荐

    WTL全称为Window Template Library WTL8.0

    WTL全称为Window Template Library WTL8.0WTL全称为Window Template Library WTL8.0WTL全称为Window Template Library WTL8.0WTL全称为Window Template Library WTL8.0

    Windows Template Library - WTL

    Windows Template Library - WTL Version 9.1 (build 5321 final) 2015-11-17。VC++下,COM开发用。

    Windows Template Library (WTL)

    Windows Template Library (WTL) is a C++ library for developing Windows applications and UI components. It extends ATL (Active Template Library) and provides a set of classes for controls, dialogs, ...

    Windows Template Library (WTL) 8.0

    Extends ATL (Active Template Library) and provides a set of classes for controls, dialogs, frame windows, GDI objects, and more. This version provides support for Windows Vista, Visual Studio 2005, ...

    WTL 9.1 5270 ReadMe 中文 汉化 中英文对照版 01d

    Windows Template Library - WTL Version 9.1 (build 5270) 2015-09-27 Windows模板库 - WTL Version 9.1 (build 5270) 2015-09-27 (水平有限,不足之处,欢迎指正交流:ybmj@vip.163.com) ________________________...

    WTL(Windows Template Library)的初学者指南

    MFC程序员的WTL指南; 基本界面,对话框与控件

    深入剖析WTL(Windows Template Library)内部实现机制

    WTL是基于ATL的对Win32界面API的再封装,相比MFC,WTL更加小巧。

    wtl8.0免资源分

    Windows Template Library (WTL) is a C++ library for developing Windows applications and UI components. It extends ATL (Active Template Library) and provides a set of classes for controls, dialogs, ...

    WTL 9.1 5321 Final Soft and ReadMe中英文对照版 37

    Windows Template Library - WTL Version 9.1 (build 5321 final) 2015-11-17 Windows模板库WTL 9.1(build 5321 final)2015-11-17 (水平有限,不足之处,欢迎指正交流:ybmj@vip.163.com) ______________________...

    wtl80,也就是wtl 8.0

    windows template library,wtl 8.0,啰嗦啰嗦两句

    WTL91 (Window Template Library)

    如果编译器提示找到atlapp.h头文件,你可以下载这个压缩包,解压其到某个目录,并在编译中设置头文件包含目录便可。

    WTL10_VS2017

    windows template library(wtl10)库,修改集成到vs2017中的一些问题。

    深入剖析WTL PDF

    WTL 是Windows Template Library 的缩写。最初,WTL 是由微软的ATL(Active Template Library)小组成员开发的一个SDK 例子。主要是基于ATL 的对Win32 API 的封装。从 2.0 后,功能逐步完善,成为了一个完整的支持...

    C++WTL80库

    C++WTL库WTL 是 Windows Template Library 的缩写。

    WTL Makes UI Programming a Joy, Part 1: The Basics - Samples

    The Windows Template Library (WTL) is available on the January 2000 Platform SDK. It is an SDK sample produced by members of the ATL (Active Template Library) team chartered with building an ATL-based...

    WTL_81_and_90

    wtl是 Windows Template Library 的简称,本文件包含两个版本: wtl 8.1 和 wtl 9.0

    WTL91_include库文件

    Windows Template Library (WTL) 9 版本, Windows 开发和UI库

    WTL开发库

    Windows Template Library

    深入剖析WTL

    WTL 是Windows Template Library的缩写。最初,WTL是由微软的ATL(Active Template Library)小组成员开发的一个SDK例子。主要是基于ATL的对Win32 API的封装。从2.0后,功能逐步完善,成为了一个完整的支持窗口的...

    WTL 8.0

    Windows Template Library (WTL) 是一个用来开发iWindows®应用程序与UI的组件,它扩展了ATL(Active Template Library),提供了一组控件,对话框,框架,GDI组件等元素,该版本支持Windows Vista 与 Visual Studio 2005,...

Global site tag (gtag.js) - Google Analytics