Click here to Skip to main content
Email Password   helpLost your password?

Kings Tools

Kings Tools

Introduction

As good as Visual Studio .NET is, I still miss some features in it. But MS knew that they couldn't fulfill every wish so they provided a way to write addins. That's what I've done. Sure, most of the functions in my Tools could also be done with macros, but I wanted them all packed together with an installer.

Tools

Run Doxygen

This command first pops up a dialog box in which you can configure the output Doxygen should produce. For those who don't know Doxygen: it's a free tool to generate source documentations. It can produce documentation in different formats like html and even windows help format! See http://www.doxygen.org/ for details. Since the dialog box doesn't offer all possible settings for doxygen, you can always edit the file Doxyfile.cfg manually which is created the first time you run it. All settings in that file override the settings you enter in the dialog box.

Doxygen configuration dialog

If you set Doxygen to generate html output, the resulting index.html is opened inside the IDE. A winhelp output (index.chm) will be opened outside the IDE.

The command available from the Tools menu builds the documentation for the whole solution. If you don't want that for example if you have several third party projects in your solution then you can build the documentation also for single projects. To do that the KingsTools add a command to the right click menu in the solution explorer.

If you want to update Doxygen to a newer version (as soon as one is released) simply overwrite the doxygen.exe in the installation directory. The same applies to the dot.exe.

TODO: find a way to integrate the generated windows help file into VS help.

Insert Doxygen comments

Doxygen needs comments that follow certain conventions to build documentation from. This part of the tools inserts them for you. Either from the right click menu in the code editor window or from the submenu under Tools->Kings Tools. Just place the caret over a method or class header. The inserted comment for a method or function would look like this:

/**
 *
 * \param one
 * \param two
 * \param three
 * \return
 */
BOOL myfunction(int one, int two, int three);

You now have to simply insert a description in the second comment line and descriptions for each parameter of the function/method. And of course a description of the return value.

You can customize the function comments by editing the files "functionheadertop.txt", "functionparams.txt" and "functionheaderbottom.txt". Please read the comments inside those files on how to do that. If you don't want to change the function comments for all your projects then you can place any of those files into your project directory (that way it will be used for your project) or inside the folder of your source files (that way it will be used only for the files inside that specific folder).

The inserted comment for a class looks like this:

/**
 * \ingroup projectname
 *
 * \par requirements
 * win98 or later, win2k or later, win95 with IE4 or later, winNT4 with IE4 
 * or later
 *
 * \author user
 *
 * \par license
 * This code is absolutely free to use and modify. The code is provided 
 * "as is" with no expressed or implied warranty. The author accepts no 
 * liability if it causes any damage to your computer, causes your pet to 
 * fall ill, increases baldness or makes your car start emitting strange 
 * noises when you start it up. This code has no bugs, just undocumented 
 * features!
 *
 * \version 1.0
 * \date 06-2002
 * \todo
 * \bug
 * \warning
 *
 */
class CRegBase

The '\ingroup projectname' means that the class is inside the project 'projectname'. That statement helps Doxygen to group classes together. Insert the description of the class right after that statement. If you want to include pictures to illustrate the class, use '\image html "picture.jpg"'. For more helpful tags you can use please check out the Doxygen website. The '\par requirements' section you have to modify yourself to fit the truth of your class. It's not necessary for Doxygen, but I found it very useful to give that information inside a class documentation. The name after the '\author' tag is the currently logged in user. Maybe you want to change that too to include an email address.

You can customize the class comments by editing the file "classheader.txt" Please read the comments inside that file on how to do that. If you don't want to change the class comments for all your projects then you can place that files into your project directory (that way it will be used for your project) or inside the folder of your source files (that way it will be used only for the files inside that specific folder).

The last few tags should be self-explanatory. Under the line '\version' I usually insert short descriptions of what changed between versions.

Build Solution stats

This is a simple line counter. It counts all the lines of all files in your solution, grouped by projects. The generated html file with the counted lines (code, comments, empty) is then opened in the IDE. Since I haven't found a way to add a file directly to a solution and not to a project the file is just opened for view in the IDE.

Dependency and Inheritance graph

These two commands build graphs of the class relations in your solution. See my previous article about this. The difference to my old tool is that it now generates graphs for all projects in the solution and puts all the graphs in one single html page.

Swap .h<->.cpp

This is something a simple macro could also do: it swaps between header and code files. For better accessibility it also is on the right click menu of the code editor. Really nothing special but it can be useful sometimes.

Colorize

This tool goes through all files of the current solution and looks for class, function and macronames. It then writes them to a usertype.dat file, makes the IDE to read that file and deletes it again. After you run this tool, all class, function and macronames of your solution appear colored in the code editor. Default color is the same color as normal keywords, but you can change that under Tools->Options, in the Options dialog select Environment->Fonts and Colors.

If you don't want the colors anymore, just run the command 'disable coloring' and everything will be in normal colors again. I didn't want to overwrite some possible usertype.dat file already created by some user so the tool simply creates a temporary usertype.dat file instead. If you want to have the colors again the next time the IDE starts, you either have to rerun the command (doesn't take very long to execute) or change the code of the tool yourself.

} End of

Have you ever wrote a bunch of code which looked like this:

Braces without comments

Ok, I admit this isn't a very good style of programming, but sometimes it can't be avoided. And in those cases the code is horrible to read because you don't know which closing brace belongs to which opening statement without scrolling or using the macro 'Edit.GotoBrace' several times. This tool provides a function which inserts comments after the closing brace automatically. The code snippet above would look like this:

Braces with comments

Comments are only inserted for closing braces of if, while, for and switch statements.

If you don't want to insert comments automatically while editing, you can turn off this function. If you just don't want those comments at specific places you have to move the caret either upwards (instead of downwards which happens if you press enter) or click with the mouse so that the caret doesn't go to the line below the closing brace. Comments are also not inserted when the opening brace is less than two lines above.

#region/#endregion for C++

VS.NET introduced to possibility to outline portions of text in the code editor. That's a very useful feature wthat helps navigating through big bunches of code. But the outlined sections are not saved between sessions. VB and C# provide keywords to outline sections. In VB its '#Region' and '#End Region', in C# its '#region' and '#endregion'. Only for C++ MS didn't provide such keywords (at least I haven't found them yet). With this tool you can now enable that feature for C++ too. To prevent compiler errors for those who have not installed this tool I used '//#region' and '//#endregion' as the keywords. With the comment lines before the compiler won't complain. Use those keywords like this:

outlined sections

Whenever you open a document with such keywords the tool will automatically create outlining sections. The section are also created when you type the '//#endregion' keyword and a matching '//#region' is found. As you can see, you can easily nest the sections. The code above would then look like this:

outlined sections

outlined sections

This function can't be deactivated. If you don't want it, simply don't use those keywords :)

Search the web

These two small addons perform a simple web site search either in the google groups or on CP. Select a piece of text in the code editor, right click to pop up the menu and then select where to search for the selected text. That's all. The search results will be opened inside VS.NET.

right click menu

Install

To install the tools, just double-click the *.msi file and follow the instructions. If the tools are not automatically activated the next time you start the IDE, then please activate them under Tools->Add-In Manager. Make sure you select both the addin and the box 'startup'.

All additional files needed for the tools are also packed in the installer, including Doxygen and the dot files. So you don't have to grab them separately from the web.

Source

Full source code is provided with these tools. The addin is written in VB.NET cause first there was just one simple tool that I wanted immediately - and VB is good enough for that. Then the tool grew and I added more functions. So the code is surely not the best example for good programming (no plan, no structure -> chaos). But maybe it might still be of interest for those who want to write their own addins. It shows a way to create submenus and how to add a toolbar.

Revision History

24.06.03 18.04.03 04.10.02 21.9.02 7.9.02 8.8.02 10.8.02 12.8.02
You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
General#region already exists
fakeymcfake2
16:45 22 Sep '09  
vc++ already included the region code:
#pragma region  Yay, built in support for regions

// Everything in here will be in a collapsible section!

#pragma endregion

Generalusefull tool
David xiao
21:59 24 Aug '09  
This is usefull tool. thanks very much. Big Grin
General:D
anhldbk
1:02 18 Aug '09  
Great work, guy! Thanks a million!

anhld

GeneralSide effect with Outlining - bug
Marc Delahousse
4:52 30 Jul '09  
Hi,

I often use the shortcut Ctrl-M-O in order to collapse all the code of a file. Unfortunately, after installing Kings Tools, I found that there is a side effect. Now, hitting enter puts the cursor on the original line, above the new line. This is incredibly annoying. I like this tool but can't live with this bug.Frown

Does anyone else get this? Is there a workaround?

Marc
GeneralRegions in VC++ 2008
TomFromCZE
2:22 23 Feb '09  
#pragma region MyRegion
#pragma endregion

Tested with VS 2008

Tomas
GeneralAnyone tried this under Vista
bobofet
8:38 24 Apr '08  
When I run VS 2005.NET in Vista with elevated privileges, I get a class not registered error when VS starts up however it works fine if I run it in normal mode?
GeneralRe: Anyone tried this under Vista
RtroActiv
17:56 3 Mar '09  
compiled the modified 2008 version below and it runs fine in Vista Home Premium. Have heard, (and to some extent experienced) problems with VS2005 in Vista all together. it's why i finally ponied up and bout 2008.:~
GeneralKingsTools for VS .NET 2008
tyrion
8:45 18 Mar '08  
Has anyone tried to build KingsTools using VS 2008? If so, I appreciate any help I can get.
QuestionRe: KingsTools for VS .NET 2008
Jens876
23:16 16 Apr '08  
tyrion wrote:
Has anyone tried to build KingsTools using VS 2008? If so, I appreciate any help I can get.


I didn´t get it too. Maybe there is anywhere already a Version of the AddIn for VS 2008?
AnswerRe: KingsTools for VS .NET 2008 - got it working [modified]
Green Chilli
22:33 2 Aug '08  
I've managed to get the add-in working under VS 2008. Here is a link to the updated source code.

I've also added a couple of shortcut keys - Ctrl+D Ctrl+D for insert Doxygen comment, and Ctrl+D Ctrl+R to run Doxygen.

It's also important to note that to install it you need to get the below files from either the install version, or get the latest versions from the project homepages.

dot.exe
doxygen.exe
hhc.exe
neato.exe
ft.dll
jpeg.dll
png.dll
z.dll

Hope this is a benefit to others out there.

modified on Sunday, August 3, 2008 6:18 AM

GeneralRe: KingsTools for VS .NET 2008 - got it working
VJorg
3:37 19 Aug '08  
I'm trying to compile your source, but don't know where to get the files you mentioned. I cannot extract the original msi file (installation fails, msiexec gives an error when trying to use it to extract files). Which project homepages are you referring to?

Thanks!

Jörg
GeneralRe: KingsTools for VS .NET 2008 - got it working
lloyd strickler
11:32 20 Sep '08  
I am using VS2005 and still can't get it to work. Does anybody have it working for 2005? I can't get to the website of the one that is said to be working. If it works can somebody post another link to it?
General>> VS 2005 | Re: KingsTools for VS .NET 2008 - got it working
Member 723285
13:07 20 Sep '08  
>> Visual Studio 2005

http://code.google.com/p/bwapi/downloads/list[^]
GeneralRe: KingsTools for VS .NET 2008 - got it working
Staffan V
0:35 16 Oct '08  
I get the message
ERROR: Could not find required file 'setup.bin' in 'c:\Program\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Engine'.
ERROR: General failure building bootstrapper
ERROR: Unrecoverable build error

so there's something wrong somewhere.
GeneralRe: KingsTools for VS .NET 2008 - got it working
October
3:10 19 Oct '09  
I have gotten it using the code from Green Chilli with VS2008&win7.

Please check your environment of your PC.

By the way, thank Green Chilli for providing the updated source code. Thanks a lot.
GeneralProject dead?
Member 15694
3:25 7 Mar '08  
I was interested in this tool for VS2005 and to integrate it with VS help system... is this project dead or is there any follow up?
Generalregions in C++
IGood
23:37 14 Nov '07  
I read that some users have had problems with the King's Tools implementation of regions with "//#region", you'll be happy to know that VS C++ does support regions with pragmas:

#pragma region Some Name
// code...
#pragma endregion


Perhaps King's Tools can update to use this method instead, since it's built into the IDE
GeneralColorize...
Michael Chourdakis
3:02 23 Sep '07  
I am looking for ways to make the usertype.dat file, and I found this one, but I can't install it and I can't seem to find the relative code in the source to make my own addin.

Could you help?
Running Visual C++ 2005.


GeneralRe: Colorize...
Michael Chourdakis
4:00 23 Sep '07  
I 've added this function to the macros (I am a VB newbie at allSmile
-------


Sub Colorize_Run()

Dim applicationObject As EnvDTE.DTE

Try ...
(your usertype.vb run() code here)
End Sub

My problem is how to initialize applicationObject. This, in your addin, is ininitialized with OnConnection(), but I don't have an on connection since this is a macro.

Plz Help .
Michael



GeneralRe: Colorize...
Michael Chourdakis
4:23 23 Sep '07  
I fixed it, simply applicationObject = DTE
It works, but it works only for my custom types. How do I add Windows Types as well ?

Michael

QuestionHow to change the code to add class & function names in the doxy comments?
Vikrant Aglawe
2:02 29 Jun '07  
The solution is really great. Smile

I was wondering if it is possible to add class & function names in the doxy comments ?
(i.e. functionheadertop for functions)

Please lemme know if possible.

Thanks,

Vikrant

vikrantaglawe@gmail.com


QuestionClass graph fails (VS 2005)
simon heffer
6:02 18 Jun '07  
I'm using the VS 2005 mod.

None of the class graphs work. I get an alert box "Operation could not be completed" and an HTML page with a broken image link. Any there logs to examine to check where its going wrong?

Ta,
Simon
AnswerRe: Class graph fails (VS 2005)
Kurnia Kosasi
6:17 24 Sep '07  
I am experiencing the same problem, anybody found a solution to this?
GeneralRe: Class graph fails (VS 2005)
andy thecoder
9:21 10 Jan '08  
Has anybody, to date, gotten this to work in VS2005? I've gotten it to show up in the menu by playing with registry settings, but it hangs or produces no graph.
GeneralRe: Class graph fails (VS 2005)
j_rietdijk
1:29 7 Feb '08  
Heey

There is a bug in de execute command. When you execute a prompt with spacebars you must used quotes ("c:\Program Files\KingTools\dot.exe" ).

So you need change the next command

applicationObject.ExecuteCommand("Tools.Shell", "/output " + dotdir + "\neato.exe -Tpng """ + dir + "dep.txt"" -o """ + Path.GetDirectoryName(applicationObject.Solution.FullName) + "\Doc\" + project.Name + "depgraph.png""")

to

applicationObject.ExecuteCommand("Tools.Shell", "/output """ + dotdir + "\neato.exe"" -Tpng """ + dir + "dep.txt"" -o """ + Path.GetDirectoryName(applicationObject.Solution.FullName) + "\Doc\" + project.Name + "depgraph.png""")

And of course for all ExecuteCommands.

Good luck


Last Updated 2 Jul 2003 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010