Environment: Visual C++ 5 & 6
When I attempted to use the various toggleheader macros freely availabe in the open source space, Developer Studio would continually crash for such simple things as the file not existing! I think this is a result of a bug in the scripting engine, when you try to open a nonexisting file. Therefore, I decided to write a true Visual Studio Add-In to solve this problem.
Here are the installation notes to copy and register this Add-In’s .DLL and to use it from Visual Studio.
- Unpack the DLL from the accompanying .zip file to the Visual Studio Add-Ins folder (typically c:program filesmicrosoft visual studiocommonmsdev98addins).
- From there, open a command window and after navigating to the aforementioned “Add-Ins” folder, run the following program.
c:program filesmicrosoft visual studiocommonmsdev98addins>regsvr32 toogleh.dll
- Once you’ve done that, start Visual Studio and click on the Tools->Customize menu option
- As you can see in the figure above, at this point the Add-In will appear in Customize dialog. Simply click the checkbox next to it and then click the dialog’s Close button.
- Now a new toolbar should be created with a single button on it representing your new Add-In. Simply click this button any time you want to open a .cpp file’s associated .h file (or vice versa)!
How it Works
The first thing the Add-In does is to determine which file it is searching for (the target file). If you have a file open that is named test.cpp or test.h, the Add-In will be searching for a target file of either test.hpp or test.h. Conversely, if the currently open file is test.h or test.hpp, the target file would be test.cpp or test.c
Once the target file has been established, the Add-In first searches for this file in the current folder. If it can’t find the it, the search continues in a subdirectory called “include” (if one exists). If the search is still unsuccessful, the Add-In then searches in the current folder’s parent folder.
Here’s a couple of examples of how the search would take place.
Currently open file : foldersrcsample.cpp
-> 1. look project foldersrcsample.h
2. look project foldersrcsample.hpp
3. look project foldersrcincludesample.h
4. look project foldersrcincludesample.hpp
5. look project folderincludesample.h
6. look project folderincludesample.hpp
Currently open file : folderincludesample.h
-> 1. look project folderincludesample.c
2. look project folderincludesample.cpp
3. look project folderincludesrcsample.c
4. look project folderincludesrcsample.cpp
5. look project foldersrcsample.c
6. look project foldersrcsample.cpp
This Add-In is absolutly free. You may copy, distribute or modify in any kind you wish.
I hope you’ll find this add-in useful in any ways. If you have any suggestions, comments etc. please feel free to email me -> [email protected]
Date Posted: August 8, 2000