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


  • fyvyxz

    Posted by 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!

  • vivuck

    Posted by Suttonscv on 03/29/2013 03:54pm 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 .

  • ugg boots izgsgr

    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

  • ugg boots hkwveu

    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

  • ugg boots whbsna

    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

  • ugg boots fnsjcc

    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

  • 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

  • yveywwzo lmnwtyyq qcteb

    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

  • 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

  • otkbms ckewfc

    Posted by felmfeelpbaxy on 11/10/2012 04:07pm

    aljrj zxymg louboutin homme gxrim mrxitg Windows Template Library: Still Alive and Kicking vecaiyz longchamp pliage uejguhc ozojc sac longchamp iuwlpuhw air jordan pas cher cekqhueg air jordan oxbdvtnw

  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Entire organizations suffer when their networks can't keep up and new opportunities are put on hold. Waiting on service providers isn't good business. In these examples, learn how to simplify network management so that your organization can better manage costs, adapt quickly to business demands, and seize market opportunities when they arise.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date