Introduction
After deciding that MFC was too bloated for my liking, I discovered WTL. I read the various articles on CodeProject about them, and was eager to try this excellent new wrapper for Win32. (Imagine... no support files necessary!)
Unfortunately, I soon discovered that my favorite part of Visual Studio, Intellisense, didn't work correctly. I was frustrated by this, because I am a heavy Intellisense user. Throughout the course of my frustration, I decided to buy Visual C++ .NET 2003. (I had VC2002 initially.) When that didn't solve my problems, although it relieved a few unrelated ones, I decided to try to find another way.
In actuality, I had a solution ready in 5 minutes. I got an idea from someone who said they included all of the WTL header files in their project. I thought that was messy, and decided to try including them in a static library. The library itself doesn't do anything special.
There may be other solutions, and if you have one, feel free to post so I can update the article accordingly. But I decided to write my first article for this, since it has helped me and hopefully will help others.
Included Source Files
In the source files linked at the top of this article, you will find a Static Library. If you don't wish to follow the steps below, you can download the source ZIP and skip to step 4. NOTE: It was created in VS2003, and uses the WTL 7.1 headers.
A Workaround
- Step 1: Create a new Win32 Project. I used "WTL71Intellisense" for the project name, because that is the version of WTL I am using. Select "Static Library" under "Application Settings". The rest remain at their default. (Precompiled Headers, no MFC)
- Step 2: Right-click on the Project name in Project Explorer. Choose "Add" > "Add Existing Item". Navigate to the '(WTL)\include' directory that you keep your WTL headers in. Select all of the items, and add them to the project.
- Step 3: Make sure you are in Release mode, and build the library. If all goes well, your library should build. Go to the "Release" directory, and find the .lib file.
- Step 4: Place the .lib file in your Library directory. Mine is C:\Program Files\Visual Studio Projects\vc7\lib directory. (with VS2003. With other installs yours may be different)
You're done! To use the library:
- Step 1: Right-click on the Project name in Project Explorer. Choose "Properties", and go to the "Linker" tab, subsection "Input". Select "All Configurations".
- Step 2: In the "Additional Dependencies", add the name of the library file. (e.g. WTL71Intellisense.lib)
Intellisense should now work correctly.
Notes
- Especially with MFC projects, as with any WTL project, be careful about name collisions in your code.
- You don't need to change anything else in your project besides linking in the library.
- Linking the library should not affect your executable.
- If you change the WTL source files, it would be wise to rebuild the library project.