|
What is WTL? Author: Richard Grimes 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: Richards answer: 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 COM and Apartments By Richard Grimes, January 7th 2000 An Introduction to WTL By Richard Grimes, January 7th 2000 An Introduction to Interface Programming By Richard Grimes, January 7th 2000 Full size articles: What is Async COM? By Richard Grimes. Microsoft Transaction Server By Richard Grimes, December 9th 1999 What COM is all about By Richard Grimes, December 6th 1999 Further Reading:
More ByteSize articles: 'ILoveYou' By Richard Grimes, 200500 COM+ 2.0 - First Announcement of Microsoft's New Technology By Richard Grimes, 100500 How to use DDX with WTL? By Girish Bharadwaj, 270300 ATL Server By Richard Grimes, 220200 COM Threading Models By Gopalan Suresh Raj, 070200 ActiveX & COM By Gopalan Suresh Raj, 270100 Type Library Info, XML and a bit of XSL for fun! by Richard Anderson 121199 COM and Apartments By Richard Grimes, 070100 What is WTL? By Richard Grimes, 070100 An Introduction to Interface Programming By Richard Grimes, 070100 Some links on COM:
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. Contribute to IDR: To contribute an article to IDR, a click here.
|
|