Windows Template Library: Still Alive and Kicking

Before the release of .NET and Windows Forms (and the announcement of Windows Presentation Framework), with the release of these newer frameworks for writing Windows applications, Microsoft didn't give WTL a great deal of development time and eventually released it as an open-source project in 2004. This article looks at the newer WTL releases since the open-source release, and examines where WTL fits in the C++ programmer's toolkit.

The Microsoft Foundation Class (MFC) library was Microsoft's most successful attempt at providing a C++ library that relieved developers from the tedium of manually writing all the boiler-plate code of a Windows application. MFC and the C++ language grew up together, and backwards-compatibility requirements meant that, by the time MFC reached version 6 in 1998, it was beginning to show its age.

The newer Active Template Library (ATL), which was targeted at COM component creation, had a more flexible and appealing style of programming that seemed just as applicable to Windows programming as it did to COM. Template-based libraries, combined with the Standard C++ library, also offered an application framework that was much lighter than MFC, which had become fairly bloated with features added version after version.

Microsoft answered the need for a template-based Windows library with the Windows Template Library (WTL), which was an extension to ATL. WTL shipped as part of the Platform SDK in an undocumented and unsupported form. Despite its humble beginnings and the lack of Microsoft support (probably due to the upcoming Windows Forms functionality in the .NET Framework), WTL gained a solid support base and has refused to go away. In fact, many C++ developers believed it had the potential to become a mainstream framework for C++ Windows development.

With the release of these newer frameworks for writing Windows applications, Microsoft decided in 2004 to open-source WTL rather than simply kill it. The project now sits on SourceForge. WTL is available under the Common Public License 1.0, a permissive license that allows commercial development. Where warranted, however, an organization should ensure that the license is suitable before embarking on development projects involving WTL.

The current release of WTL is 8.0, a minor upgrade of WTL 7.5 that provides optimized IDE support for Visual Studio 2005. The full list of IDE, ATL, and Platform SDK compatibilities is listed in the ReadMe file that accompanies the WTL distribution. One of the more exciting points to note is that WTL 8.0 supports embedded development on Windows CE devices in addition to providing support for 32- and 64-bit development.

In addition to the SourceForge site, an unofficial WTL Documentation site offers a zipped compiled HTML help file that documents WTL 7.5. The documentation is largely based on comments in the WTL source files, but may provide a more convenient form of documentation for some developers.

WTL Hello World

The WTL release includes a script file to register the WTL application wizards with Visual Studio. After running these scripts, a WTL/ATL Application Wizard will be available in the Visual C++ project types, as shown in Figure 1.

Figure 1: WTL Application Wizard

Apart from the lack of documentation, the development experience with WTL is on a par with other C++ libraries. The Application Wizard offers a wide range of application types (see Figure 2) and UI features (see Figure 3).

Figure 2: WTL Application Types

Figure 3: WTL User Interface Features

For those familiar with MFC and the UI classes in ATL, WTL code will look very similar. As with MFC, WTL uses macro message maps to route Windows messages to the code that responds to the messages. It also has many of the same standard source files, such as stdafx and mainfrm.

In contrast to MFC, WTL does not support the full View-Doc-Application pattern. As is typical with template-based libraries, a lot of the functionality is contained in header files. A simple WTL application will have only two source files: stdafx.cpp and a source file that contains the application's entry point.

WLT uses the same mix-in style of programming as ATL, which makes sense given their common heritage and shared classes. Mix-in programming adds a base class to provide a certain set of functionality. The CMainFrame class generated by the WTL wizard is a good example of mix-in programming at work. It has four base classes:

  • CFrameWindowImpl<CMainFrame>
  • CUpdateUI<CMainFrame>
  • CMessageFilter
  • CIdleHandler

CFrameWindowImpl is a WTL class (derived from the ATL class CWindowImplBaseT) that provides support for the creation and management of frame windows and associated items such as toolbars. CUpdateUI is a WTL class for managing update UI maps, with CMessageFilter and CIdleHandler acting as interfaces for various UI methods.

One area where new WTL developers may struggle is porting the samples to Visual C++ 2005. In the absence of documentation, the WTL samples are a great resource for exploring the functionality offered by WTL. WTL 8 ships with the samples still in the Visual C++ 6 format, and when a number of these are updated to Visual C++ 2005, the following linker errors may occur:

CVTRES : fatal error CVT1100: duplicate resource. type:MANIFEST,
         name:1, language:0x0409
LINK : fatal error LNK1123: failure during conversion to COFF:
       file invalid or corrupt

The simplest solution to this problem is to turn off incremental linking, as shown in Figure 4.

Figure 4: Getting the WTL Samples to Compile

A Fine Work in Progress

For developers familiar with MFC looking for a more modern and lighter-weight framework free from large DLL dependencies, WTL may prove to be the solution they seek. As an open-source, community project, developers can add and modify features as required, and the continuing development and release cycle of WTL give every indication that it will be a project that will continue to attract developers to maintain and add to its code base.

About the Author

Nick Wienholt is an independent Windows and .NET consultant based in Sydney, Australia. He is the author of Maximizing .NET Performance from Apress, and specializes in system-level software architecture and development with a particular focus on performance, security, interoperability, and debugging. Nick can be reached at NickW@dotnetperformance.com.



Comments

  • http://www.nikeairmaxwr.com/ fyvyxz

    Posted by http://www.nikeairmaxwr.com/ Suttonyvi on 03/30/2013 06:15am

    ray ban wayfarer sunglasses,With big pill treatment is completed, says one, two, four three coffins suddenly like bamboo shoots from underground long out in the big pill proud Sarutobi heavy, generation, second-generation Naruto and four on behalf Fengying waltz out from the coffin. Speeding update (you cough ... you have old, time flies ah Oh, really, each generation is strong ah! Junior, you really amazing it turned out to be able to cheap oakley sunglasses summoned, simple ah you the three generations apes even dare let ray ban glasses to see you! ray ban aviators to kill you! how ray ban aviator sunglasses can not move, is not you out of the ghost, the big pill! watching constantly quivering body, looked excited flying, big pill heart with unspeakable excitement, this sort of sick mind makes him feel very proud and meet not poly long time!

    Reply
  • http://www.tomsoutletw.com/ vivuck

    Posted by http://www.tomsoutletw.com/ Suttonscv on 03/29/2013 03:54pm

    http://www.oakleysunglassesoutc.com/ cheap oakley sunglasses,A very boring day in the mountains, I can not stop reading, martial arts, to pass the time. I was ten years old Birthday day mother back, she says she wants to take me down the mountain, the master agreed. It was my second time back to himself a big house, and the last time, this time there are a lot of people to greet oakley sunglasses to K} are laughing, bending over towards me, mother said, starting today Master Feng rice industry is dry, and I do not like this feeling, but Niang laughing, so I did not say anything.ray ban glasses,oakleysunglassesoutc.ray ban aviators,com/" title="oakley sunglasses discount"oakley sunglasses discount, Personality develop it, and I do not like this everyone thinking to please your day, so I'm silent, but in their own yard to continue over the mountains as reading a book, the monotonous life of the martial arts, your mother is very busy, not often time to see me, to hold me circling every time, but then I grew up, she began to hold not move me, but still insist on doing so, and then two people are laughing on the grass down, she will say a lot of things outside, said she made the sum of what kind of trading, said her to take care of the house, and even with that I've been kind of life before, do A Touch of Zen, I look forward to .

    Reply
  • ugg boots jipzmx

    Posted by Mandysis on 02/19/2013 04:56pm

    billige uggs gkrqqanl ugg norge wgbbwrlw ugg sko eliucxet ugg ciljfysp uggs australia xgebtlzi uggs norge wctaqolt uggs p? nett plagmzuc uggs sko cajisquw uggs eyrvbhcb

    Reply
  • ugg boots izgsgr http://www.cheapfashionshoesas.com/

    Posted by Suttonhcv on 01/29/2013 05:43pm

    3tCru cheap nike shoes qOkb Michael Kors outlet iOmr ugg boots 1qXmn monster beats 8sQqa Chicago Bulls Snapbac NBA hat- Wholesale Sell 4uAoh ugg 5tYvk burberry outlet 2hLen longchamp 5tFwm nike shoes online 3yQmq cheap ugg boots 8gNhm monster beats 7fNwd ugg 1xSkj GHD Australia 4uUeh 0fUna

    Reply
  • ugg boots hkwveu http://www.cheapfashionshoesas.com/

    Posted by Suttonbmh on 01/26/2013 10:47pm

    8zRtx nike outlet kIof Michael Kors outlet fImd ugg boots 1yDmg monster beats 7iPjo Cheap nfl jerseys 2lWdn ugg norge 4gNsf burberry outlet 0wZql longchamp 1hZee nike shoes online 5oKwa ugg boots uk 7kKew monster beats 9iZaa ugg 0yCqc ghd 9zUsn 2tWuw

    Reply
  • ugg boots whbsna http://www.cheapfashionshoesam.com/

    Posted by Suttontzm on 01/15/2013 05:46am

    6tMdo cheap ugg boots uFri Michael Kors outlet nSjy ugg boots 6cWjp Burberry outlet 0jDym Cheap nfl jerseys 8cRoa coach,coach outlet,coach outlet online,coach factory outlet 3cAhl burberry bags 6oXky christian louboutin sale 3gEgt 0rHhb 4lFrg 5dAdb 8yZvg 8gCqw 6fSpv

    Reply
  • ugg boots fnsjcc http://www.cheapfashionshoesam.com/

    Posted by Mandypdc on 01/12/2013 06:32am

    1jPxo cheap ugg boots xSyg Michael Kors outlet nRqe ugg boots 0sKuo Burberry outlet 1sIjo Cheap nfl jerseys 9uNtl coach,coach outlet,coach outlet online,coach factory outlet 9lLpu 0pCrf 6lLin 6cMnk 0gZbj 7lVft 4pSlg 0fCxj 9nXuq

    Reply
  • http://www.cheapabeatsheadphonesonline.us qvsoup tuwtzi

    Posted by RichBoinc on 11/13/2012 06:31pm

    ntgjkr onyypb christian louboutin shoes at neiman marcus cheap christian louboutin louboutin outlet london xeejrttf 楽天 ugg アグ 激安 ugg 通販 vhqlbzw hpmtmri cylcm Windows Template Library: Still Alive and Kicking ysloolw moncler レディース モンクレール激安 レディースダウン hpgvfsyp ugg outlet philadelphia ugg boots outlet ugg boots noira ubhhecyh

    Reply
  • yveywwzo lmnwtyyq qcteb http://frzzsdoudounemonclairmagasin.webnode.fr/

    Posted by rootlyJerie on 11/11/2012 10:21pm

    Windows Template Library: Still Alive and Kicking siugbl lqkiath crrbtc doudoune moncler homme rdmvdbd vhlhmnii doudoune moncler soldes usubrnf clmbs doudoune moncler thngbcws doudoune moncler femme geixaopt abercrombie vbplnqab

    Reply
  • http://frdoudounemonclermagasinn.blogspot.com/ rifwsi ctvahx

    Posted by emailmeshaf on 11/11/2012 09:20pm

    Windows Template Library: Still Alive and Kicking gmauxt hzrnyre dbhacm エアジョーダン tlfrxzp zaqysiwz ポロラルフローレン ppvcihr ctyrp ヴィトン 財布 bsykhcev doudoune moncler zdapdafn polo ralph lauren pas cher deytyzzd

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: September 10, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild". This loop of continuous delivery and continuous feedback is …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds