Library Zone Articles
External Articles
Byte Size

Discovery Zone Catalogue
Diary
Links
Bookstore
Interactive Zone Ask the Gurus
Discussion Groups
Newsletters
Feedback
Etc Cartoons
Humour
COMpetition
Advertising
Site Builder ASP Web Ring ASP Web Ring


The Developer's Resource & Community Site
COM XML ASP Java & Misc. NEW: VS.NET
International This Week Forums Author Central Find a Job

What is WTL?

Introduction

WTL has been whispered about for well over a year, the rumour was that it was used internally at Microsoft and that it was based on ATL. This of course got the attention of the ATL developer community, who have been writing UI code for ATL controls ever since ATL 1.1, but have found that more often than not the code they were writing was pure Win32 GDI code. I have something to tell you - WTL is not much different.

Is this a disappointment? No, because ATL itself is just a thin wrapper over COM and this is its strength. Sure, you have to know COM to write ATL, but the extra learning for the ATL parts was small compared to the amount of effort you made to learn COM. Contrast that to other class libraries, where the majority of the effort is learning the class library, and what do you know at the end - well not much about COM, that's for sure.

WTL is similar. You have to know about Win32 windowing and GDI. But if you do know about them then WTL is a breeze, no more then that, it is a breath of fresh air. If you do not know about GDI and Win32 windowing, then you are better off writing VB to do UI code.

So what does WTL have?

It has a basic framework of application types. Note that although you do not have the documents that MFC has, you do have views. There is a lot of code in WTL to give you view management and to make it easy for you to add your own code. WTL has an AppWizard that gives you SDI, MDI and Multi threaded SDI applications (multi SDI is like IE or Windows Explorer, where it looks like you have multiple instances open, but they are just multiple windows of the same process). In addition, your application can be dialog based or 'view' based. The views can be CWindowImpl based, or based on a control or even on a HTML page hosted in IE. You can also choose whether your application has a rebar, command bar (CE-like), toolbar and/or a status bar. In addition, the application can host ActiveX controls and can be a COM server.

There are several options about the views you can use. WTL provides splitter window classes (so that you can have two windows in a view) and scroll window classes (so that your window can be smaller than the 'view' that it is presenting). There is also a form of MFC's UpDateUI, but it doesn't work quite the same - the main difference is that you indicate the items that can be updated with a map, and you have to add code to your class to perform the UpdateUI. There is also DDX/DDV support which, again, is similar to MFC, but with the difference that you have a map that implements DoDataExchange and that you need to add code to call it.

There are now GDI classes. However, the HDC wrapper class is like CWindow in that it is a very thin wrapper - it adds very little new functionality. However, you do have support for playing meta files and for OpenGL. The main use I guess will be the derived classes for printer DCs - WTL has printer support and even print preview. There are also wrapper classes for the GDI objects, pens, brushes, regions etc

It has wrappers for all of the Win32 (and W2K) Common dialogs, again, these are fairly thin wrappers, but it makes asking for a font, or a file really quite simple.

The old AtlControls.h has been incorporated, and there are some new wrapper classes for the W2K controls, as well as some classes for 'controls' that are not Win32, like a Command Bar clone, a bitmap button, hyperlink and wait cursor.

WTL finally brings message cracking to ATL! There are new MSG map macros that will crack the Windows message and call the function in your class with the appropriate 'cracked' parameters. The only pain is that you have to search through the header to determine what the parameters of that method should be!

Finally, there are utility classes, the most significant is CString. Yes, this is an MFC clone class (the string is copy on write) and has (as far as I can tell) all the methods of the MFC version. There is also a wrapper class for the find file API and classes for CRect, CSize and CPoint.

Summary

If you intend to write a Win32 UI application then I recommend that you try WTL before thinking about MFC. If you write your code in WTL it will be leaner and more efficient and you will have the advantage of the COM support in ATL, which is sadly missing in MFC.

You can find WTL in the Jan 2000 Platform SDK under the Source Code section of the MSI options page.


Mail a question to the author!!

As part of the IDevResource commitment to Open Publishing, all of our authors are available to answer all of your trickiest questions at Author Central. For information about the authors, or to mail a question, visit them at Author Central.

Did you like this article?

If you liked this article, tell us about it. You can email your remarks to us at [email protected]

A question raised by the article on the dev-com discussion list:

Taras Tielker asked:
Are "atlcontrols.h" header and WTL comparable or does WTL introduce a new framework?"

Richards answer:
Sorry, you will find it on the list.

There was also the following question:

Q: I was reading "Beginning Atl 3 Com Programming" and I was wondering about the relationship between the "Atlcontrols.h" (ATLs thin wrapper classes for controls like ListView) header discussed in ch.7 (I took a quick look at that chapter) and WTL. Are they comparable or does WTL introduce a new framework?

A: WTL has a file called AtlCtrls.h which effectively has the code from AtlControls.h. So it means that you no longer have to go hunting for the ATLCon example!

You use the classes in AtlCtrls.h in the same way as you use the ones in AtlControls.h. WTL does add more controls - W2K tools and some classes for controls that do specific things like a bitmap button and a check box listbox.

Want to read more articles by this author?

Try these:

Byte size articles:

ATL Server By Richard Grimes, 220200
Richard's report from European Devweek 2000, and VCDC Bonn 2000 gives an insight into the new ATL Server technology.
Go To Article.

COM and Apartments By Richard Grimes, January 7th 2000
A discussion on the creation and use of "Apartments" in Win32.
Go To Article.

An Introduction to WTL By Richard Grimes, January 7th 2000
Richard gives a basic introduction to WTL.
Go To Article.

An Introduction to Interface Programming By Richard Grimes, January 7th 2000
Richard describes the background to interfaces.
Go To Article.

Full size articles:

What is Async COM? By Richard Grimes.
Go To Article

Microsoft Transaction Server By Richard Grimes, December 9th 1999
Introduces Microsoft Transaction Server
Go To Article.

What COM is all about By Richard Grimes, December 6th 1999
An introductory article to COM, covering all basics including OLE, Activex and DLL's.
Go To Article.

Further Reading:

  1. Microsoft Transaction Server By Richard Grimes, introduces Microsoft Transaction Server
  2. What COM is all about By Richard Grimes, an introductory article to COM, covering all basics including OLE, Activex and DLL's.
  3. String Binding Moniker By Frank Rem, shows how a SB Moniker resolves a connection with a DCE RP server running on Linux using a VB client.
  4. Inside COM Monikers By Davide Marcato, on COMdeveloper.com. monikers are still one of the most clever but at the same time most misunderstood idioms in the COM universe. Davide explains them.

More ByteSize articles:

'ILoveYou' By Richard Grimes, 200500
Richard Grimes discusses the release of the Microsoft patch for the 'ILoveYou' virus. Go To Article.

COM+ 2.0 - First Announcement of Microsoft's New Technology By Richard Grimes, 100500
Richard Grimes reports on the recent news about COM+ 2. Go To Article.

How to use DDX with WTL? By Girish Bharadwaj, 270300
Go To Article.

ATL Server By Richard Grimes, 220200
Richard's report from European Devweek 2000, and VCDC Bonn 2000 gives an insight into the new ATL Server technology.
Go To Article.

COM Threading Models By Gopalan Suresh Raj, 070200
Gopalan explains the differences in COM and Win 32 threading models.
Go To Article.

ActiveX & COM By Gopalan Suresh Raj, 270100
Gopalan explains the basics of ActiveX / COM as a truly distributed Object Oriented Architecture.
Go To Article.

Type Library Info, XML and a bit of XSL for fun! by Richard Anderson 121199
This article assumes you understand COM, Type Libraries, XML and enough about VB that you can either use the code as a starting point, or, translate it into another language.
Go To Article.
This article can be downloaded: Zip File (76kb).

COM and Apartments By Richard Grimes, 070100
A discussion on the creation and use of "Apartments" in Win32.
Go To Article.

What is WTL? By Richard Grimes, 070100
Richard gives a basic introduction to WTL.
Go To Article.

An Introduction to Interface Programming By Richard Grimes, 070100
Richard describes the background to interfaces.
Go To Article.

Some links on COM:

  1. https://www.microsoft.com/com/ Microsoft's COM pages
  2. COMdeveloper.comVisit the COMdeveloper Web site for news items, articles, master classes, book reviews, a listserv, competitions, and a newsletter on COM, DCOM, ATL, and COM+ for VB, Java, and C++ developers.
  3. Chappell & Associates Visit the site hosted by Chappell & Associates to learn more about their seminars, videos, and articles on distributed computing, objects, and more.
  4. Codemarine, Inc. Visit the CodeMarine Web site to find information about in-depth COM training, mentoring, and consulting offerings.
  5. DevelopMentor Visit the CodeMarine Web site to find information about in-depth COM training, mentoring, and consulting offerings.


Author Bio:

Author: Richard Grimes

Richard Grimes started programming aeons ago on 8-bit computers and hasn't looked back since. He has spent an interesting time as a research scientist (the little known "Grimes Effect" is his creation), underpaid time as a computer trainer and done time as a distributed object developer.

ATL took hold of Richard while he was part of a team developing a COM-based workflow system and its elegance and simplicity has had a lasting effect on him. Although his is not an obsessively pure COM existence, he finds that an ATL-assisted COM lifestyle gives him more time to enjoy his garden.

Go to Richards pages in Author Central.


Click here

Contribute to IDR:

To contribute an article to IDR, a click here.

To contact us at IDevResource.com, use our feedback form, or email us.

To comment on the site contact our webmaster.

Promoted by CyberSavvy UK - website promotion experts

All content © Copyright 2000 IDevResource.com, Disclaimer notice

Learn C#

WTL Introduction

Code Project

Visit the IDR Forums

Join the Developers Webring