Click here to Skip to main content
13,548,809 members
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 22 Sep 2006
Licenced CPOL

CvsIn Add-in for Visual Studio .NET 2002 and 2003 and Visual Studio 2005

, 22 Sep 2006
Rate this:
Please Sign up or sign in to vote.
CvsIn add-in for Visual Studio .NET 2002 and 2003 and Visual Studio 2005.

Sample Image - CvsInNetAddin.jpg


I have used CvsIn by Jerzy Kaczorowski for Microsoft Visual Studio 6.0 for years. Although it is not very powerful, it is quite handy like the commit button. Microsoft Visual Studio also allows to define custom shortcut keys, such as Ctrl+D, Ctrl+U, and Ctrl+M, just like WinCvs. It is a pity that CvsIn was not updated later to support the new versions of Visual Studio. I continued the development to support MS Visual Studio .NET 2002 and 2003. However, some interface changes in Visual Studio 2005 made the old version not working. Other people might still be using this add-in, so I decided to share the code here.

Points of interest

Information output pane

A new information output pane is introduced for the CvsInNet version.

// This block of code is to create a "CvsIn" pane
// in Output window in function OnConnection.

IfFailGoCheck(m_pDTE->get_Windows(&spWindows), spWindows);

pDisp = NULL;
IfFailGoCheck(spWindow->get_Object(&pDisp), pDisp);

spOutputWindow = pDisp;
if (spOutputWindow == NULL)
    return E_FAIL;


hr = spOutputWindowPanes->Item

if (FAILED(hr))

There is a function defined in the class CCommands, sometimes CConnect, in the AppWizard generated code:

void CvsInPrintToOutput(LPCTSTR lpszMessage, BOOL bPrefix = TRUE);

to show the message.

For example, this code outputs the welcome message:


CvsInPrintToOutput(strMsg, FALSE);

Here is the message:

Up and running! [2006/09/23 13:02:04.250]

Note: The AICIntetrationManager is not used in CvsInNet.

Other modules have to specify the CCommands instance to output the message.


Custom add-in bitmaps

Please note that the transparency color has been changed since Visual Studio .NET 2002 to a special green color, RGB (0, 254, 0). The custom bitmaps embedded in the add-in DLL can still be used in VS.NET 2002 and 2003. Things have changed in VS 2005, like a resource DLL used to store the custom bitmaps. In the Eegistry, the strings SatelliteDllName and SatelliteDllPath are used for this purpose.

The interface of the command bar is also different in VS 2005, compared with VS.NET 2002 and 2003.

In VS.NET 2002 and 2003, it is the Office command bar:

CComPtr<Office::_CommandBars>   pCommandBars;
CComPtr<Office::CommandBar>     pCommandBar;
IfFailGoCheck(m_pDTE->get_Commands(&pCommands), pCommands);

and m_pDTE is defined as CComPtr<EnvDTE::_DTE> m_pDTE.

While in VS 2005, Microsoft_VisualStudio_CommandBars is used.

CComQIPtr<_CommandBars>         pCommandBars;
CComPtr<CommandBar>             pCommandBar;

and m_pDTE is defined as CComPtr<EnvDTE80::DTE2> m_pDTE.

The command information is defined on top of ConnectNet.cpp.

static CCommands::CommandInfo s_commandList[] =
    {L"CvsInOptions",               "", true,  false, IDB_CVS_OPTIONS, IDS_CMD_OPTIONS},
    {L"CvsInWinCvsSessionsManager", "", false,  false, 0, IDS_CMD_WINCVSSESSIONSMANAGER},
    // ...

    {L"CvsInWizard",                "", true,  false, IDB_CVS_WIZARD, IDS_CMD_CVSINWIZARD},

The resource number IDB_CVS_OPTIONS must have the same resource number as the one in the resource DLL, because SatelliteDll is not used in CvsIn for VS.NET 2002 and 2003.

The AddNamedCommand code for VS 2005 is:


The fifth parameter, VARIANT_FALSE, means not to use the MS Office bitmaps.

The Registry file has satellite information:

val SatelliteDllName = s 'CvsInUI.dll'
val SatelliteDllPath = s '%MODULE_PATH%'

Among them, %MODULE_PATH% is a custom entry, which will be updated by the function UpdateRegistry in the class CCommands (from the MS Automation sample).

#if _MSC_VER < 1400
 static HRESULT WINAPI UpdateRegistry( BOOL bRegister )
  _ATL_REGMAP_ENTRY rgMap[ 2 ];
  memset( rgMap, '\0', sizeof( _ATL_REGMAP_ENTRY ) * 2 );

  TCHAR szModule[_MAX_PATH];
  GetModuleFileName(_Module.GetResourceInstance(), szModule, _MAX_PATH);
  PTCHAR pchSlash = strrchr( szModule, '\\' );
  if( pchSlash != NULL )  *pchSlash = '\0';

  rgMap[ 0 ].szKey  = OLESTR( "MODULE_PATH" );
  rgMap[ 0 ].szData = T2OLE( szModule );

  return _Module.UpdateRegistryFromResource(IDR_REGISTRY_VC8, 
                                   bRegister, rgMap );

Debug the add-in

If you want to debug your add-in DLL, you may follow these steps (from VS 2005 Automation samples):

  1. In the Solution Explorer, right-click in the project and select Properties.
  2. Open Debugging, and make the following changes:
    • In "Command", enter the path to devenv.exe (e.g., c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe).
    • Set "Command Arguments" to /resetaddin RegExplore.Connect.
    • In "Working Directory", enter the directory containing devenv.exe (e.g., c:\Program Files\Microsoft Visual Studio 8\Common7\IDE).

Some improvements

Some thread refinements to reduce the quick command button click crash.

WWhizInterface and usage

Use DllRegSrv32 to register the add-in DLLs. For VS 2005, make sure the resource DLL CvsInUI.dll is put under the directory 1033 of your add-in DLL.

If you want to use the wizard, WWhizInterface has to be installed. If you want to debug the CvsIn add-in DLL, the debug binaries of WWhizInterface are also needed. Please refer to WWhizInterface: Enhancements to the Visual C++ Automation Interface for more details.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Australia Australia
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionAddin XML Pin
alex_ng2-Mar-09 20:35
memberalex_ng2-Mar-09 20:35 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180515.1 | Last Updated 22 Sep 2006
Article Copyright 2006 by jiulun
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid