How to change the title bar text of Visual Studio

2019-01-16 06:04发布

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>?

11条回答
该账号已被封号
2楼-- · 2019-01-16 06:16

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

查看更多
叛逆
3楼-- · 2019-01-16 06:19

Just another extension to change the Visual Studio titlebar by defining it as an expression: http://visualstudiogallery.msdn.microsoft.com/2e8ebfe4-023f-4c4d-9b7a-d05bbc5cb239

The setup that makes use of a "title expression" makes this plugin quite flexible.

查看更多
疯言疯语
4楼-- · 2019-01-16 06:22

Check out latest release of VSCommands 2010 Lite. It introduced a feature called Friendly Solution Name where you can set up a regex pattern to extract branch name from folder structure and have it placed in Visual Studio main window title. More details: http://vscommands.com/releasenotes/3.6.8.0 and http://vscommands.com/releasenotes/3.6.9.0

MSDN Download Page

查看更多
放荡不羁爱自由
5楼-- · 2019-01-16 06:24

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!");            
}
查看更多
三岁会撩人
6楼-- · 2019-01-16 06:25

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

查看更多
家丑人穷心不美
7楼-- · 2019-01-16 06:29

I just created a small Visual Studio extension that can help: http://visualstudiogallery.msdn.microsoft.com/f3f23845-5b1e-4811-882f-60b7181fa6d6

This small extension will detect whenever two instances of Visual Studio are running and change the window title of Visual Studio to include the parent folder name of the solution. It will therefore change SolutionFolder - Microsoft Visual Studio into SolutionFolderParent\SolutionFolder - Microsoft Visual Studio.

This is particularly useful when branching a solution: it becomes possible to easily identify which branch you are working on, in the case where both would have the same solution name.

Official page here: http://erwinmayer.com/labs/visual-studio-2010-extension-rename-visual-studio-window-title/

查看更多
登录 后发表回答