Click here to Skip to main content
15,879,239 members
Articles / Desktop Programming / WTL
Article

Using WTL with Intellisense

Rate me:
Please Sign up or sign in to vote.
3.38/5 (11 votes)
24 Dec 20033 min read 53.8K   512   15   6
Normally, Intellisense doesn't work correctly with WTL. Here is a workaround.

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralWorkaround to let IntelliSense work with any user-defined headerfile Pin
Troubelman19-Jan-05 21:41
Troubelman19-Jan-05 21:41 
GeneralExellent! Pin
Ernesto D.27-Nov-04 22:30
Ernesto D.27-Nov-04 22:30 
GeneralSimpler solution for VC 6.0 Pin
weelink15-Jan-04 3:17
weelink15-Jan-04 3:17 
GeneralSome advertising... Pin
Ralph Wetzel25-Dec-03 0:59
Ralph Wetzel25-Dec-03 0:59 
GeneralRe: Some advertising... Pin
WREY1-Jan-04 15:34
WREY1-Jan-04 15:34 
GeneralRe: Some advertising... Pin
Ralph Wetzel2-Jan-04 0:50
Ralph Wetzel2-Jan-04 0:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.