Visual Studio Source Code Control Provider Switcher

Environment: VC++ 6.0 SP4, Win95/98/NT/Me/2K/XP

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 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_LARGE and 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.

References

An improved hyperlink control, by Giancarlo Iovino.


All questions, comments, or feedback are always appreciated.

Downloads

Download Add-in - 27 Kb
Download Source - 47 Kb


Comments

  • Dead links ?

    Posted by jpcre on 12/15/2005 12:06pm

    Cannot download Add-in or Source. Open CodeGuru site map instead.

    Reply
  • Another SCC switcher option

    Posted by cbecker on 10/19/2004 02:24pm

    Give this one a try: TraySource Runs in the tray and works with all SCC providers

    Reply
  • missed a file in the zip files.

    Posted by jackliusr on 08/29/2004 11:09pm

    SCCProvider.def is missed in the source zip file

    Reply
  • Documentation

    Posted by Legacy on 10/04/2002 12:00am

    Originally posted by: Maarten

    Hi Bassam,

    the add-in looks really handy, but I was wondering if you could add some documentation.
    At the moment, what I would like to know is:
    - what do the numbers mean in the options window. What if you leave a blank field? Can I bypass these extra source control options? (I would like to use my regular Visual Studio settings)
    - if I choose to remove source control integration and reconnect to source control later, will my source control bindings be restored or will I need to add my projects again to source control?

    Thanks in advance,
    Maarten

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

  • Companies must routinely transfer files and share data to run their business, work with partners, and speed operations. However, many find the traditional approach to file transfer lacks necessary security, is too complex and difficult to manage, does not support the levels of automation needed, and breaks down when addressing the file transfer requirements of new areas like Big Data analytics and mobile applications. This QuinStreet SmartSelect discusses how the changing business environment is making the use …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds