Click here to Skip to main content
15,881,704 members
Articles / Desktop Programming / MFC
Article

Visual Studio Source Code Control Provider Switcher Add-in

Rate me:
Please Sign up or sign in to vote.
4.56/5 (2 votes)
29 May 20023 min read 76.4K   975   13   9
This article shows how to create a VS Add-in that allow you to change the source code control provider

SCC Provider

Introduction

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 up 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. Since I'm including the source code in this article, I decided against showing code snippets because it wasn'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.

Creating an Add-in

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 proceeded to create 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.

The source code to complete your add-in can be found in the downloadable zips.

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_LARGE and IDR_TOOLBAR_MEDIUM in your add-in workspace.

Limitations in this add-in:

For the life of me, I can't seem to 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.

All questions, comments, or feedback are always appreciated.

History

30 May 2002 - updated source.

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
Systems Engineer
United States United States
Bassam Abdul-Baki has a Bachelor of Science (BS) degree and a Master of Science (MS) degree in Mathematics and another MS in Technology Management. He's an analyst by trade. He started out in Quality Assurance (QA) and analysis, then dabbled in Visual C++ and Visual C# programming for a while, and then came back to QA and analysis again. He's not sure where he'll be five years from now, but is looking into data analytics.

Bassam is into mathematics, technology, astronomy, archaeology, and genealogy.

Comments and Discussions

 
GeneralCool ! Pin
Jim Crafton30-May-02 2:40
Jim Crafton30-May-02 2:40 
GeneralRe: Cool ! Pin
Bassam Abdul-Baki27-Jun-02 14:36
professionalBassam Abdul-Baki27-Jun-02 14:36 

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.