views:

1147

answers:

4

We work on several different branches of the same code, and when working on two branches at once, it can become confusing and time wasting.

Presently, the VS title bar has the text <solution-name> - Visual Studio.

Is it possible for me to write an extension that will make that text <solution-name>: <branch-name> - <Visual Studio>?

A: 

In the VS automation model there is

_DTE.MainWindow.Capation

which you could start with.

See http://msdn.microsoft.com/en-us/library/envdte._dte.mainwindow.aspx

Richard
+1  A: 

Trying to set MainWindow.Caption throws an exception. You have to use the Win32 SetWindowText function to change the title, but beware: Visual Studio resets the title bar text at the drop of a hat, so you should implement a Timer to keep setting your desired text. The following code from the Connect class of the add-in will permanently (or, as long as the add-in is running) keep the title bar text as "Hello World!"

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    resetTitleTimer = new Timer(new TimerCallback(SetMainWindowTitle), "Hello world!", 0, 10);
}

[DllImport("user32.dll")]
private static extern bool SetWindowText(IntPtr hWnd, string lpString);
private void SetMainWindowTitle(object state)
{
    IntPtr hWnd = (IntPtr)_applicationObject.MainWindow.HWnd;
    SetWindowText(hWnd, "Hello World!");            
}
ProfK
A: 

To be honest, I am not sure I am understanding your question correctly, but I had asked one here on SO that seems to be about a similar problem:

Working with different versions/branches of the same Visual Studio 2005 solution

js
A: 

Perhaps a simpler solution would be to use virtual desktops? Spacial arrangement is easier to remember, you could group any related windows with the corresponding VS, and switching would be simpler.

Eevee