Environment: VC++ 6.0 SP4, Win95/98/NT/Me/2K/XP
One of the many aggravations of Visual Studio is the inflexibility in changing the source code control (SCC) provider. After researching the problem, I found that all SCC provider information is stored in the Registry under
HKEY_LOCAL_MACHINE\SOFTWARE\SourceCodeControlProvider. If you open the Registry and go to this key location, you will, more or less, find the keys self-explanatory. My first attempt to work with this was to create a batch file to change the Registry key for me. I then decided to learn how to create add-ins and this is my first add-in project. Because I'm including the source code in this article, I decided against showing code snippets; they aren't very necessary. This really is a very simple add-in that shouldn't be all that difficult to follow. Hope it meets everyone's approval.
To begin, open Visual C++ and create a new Workspace using the DevStudio Add-in Wizard. Other articles might say that using a wizard is bad, which I tend to agree with, but for a first-time user, that's all one usually has or knows. Give your project a name and click OK. Fill in the add-in name and add a description. This should create various files in your project, among which is Commands.cpp.
Open up Commands.cpp and go to
STDMETHODIMP CCommands::YourProjectNameCommandMethod(). This is where your code gets called. Next, I created a dialog that accessed the Registry, and called it using
dlg.DoModal() from the previous CCommands' function. Once you're done setting it up, building it should create an add-in DLL that Visual Studio can use.
To use the DLL from within Visual Studio, go to Tools, Customize, or right-click on the menu area and select Customize. Click on the "Add-ins and Macro Files" tab and select browse to search for your add-in. Remember to change the file type at the bottom of the browse dialog from "Macro Files" to "Add-ins;" otherwise, you won't see it. Once selected, click Open, then Close, to see a new toolbar appear.
Fixes to Common Problems Found
After selecting your add-in, the name should appear in the "Add-ins and Macro files" tab in the Customize dialog. If you highlight your add-in, the description that you added in the wizard appears on the right-hand side. This can be changed in the String Table in the resources window. To change the add-in string that appears in the left hand side, search for
DECLARE_REGISTRY in DSAddin.h and change the second argument to fix it.
To change the toolbar icon, modify
IDR_TOOLBAR_MEDIUM in your add-in workspace.
Limitations in this Add-In
For the life of me, I can't figure out how to change the toolbar name programmatically. Visual Studio tends to name all new toolbars as Toolbar#. This seemed to be the most difficult thing to change. To change it on startup, open up the Customize dialog and click on the "Toolbars" tab. Change the name of the toolbar to whatever you want and click OK.
Recompiling the project without unselecting the add-in and closing Visual Studio. Will have to look into this one some more.
Changing the SCC Provider without Having to Close Visual Studio
Once I find more documentation on what the registry values under the Options key are, I will replace them with something more readable.
Building my project under DEBUG mode will probably fail. The problem is due to a hyperlink class that I'm using in my About dialog.
An improved hyperlink control, by Giancarlo Iovino.
All questions, comments, or feedback are always appreciated.
DownloadsDownload Add-in - 27 Kb
Download Source - 47 Kb