我经常使用Visual Studio的多个实例,通常在同一解决方案的不同分支上工作.
VC6用于在标题栏中显示当前源文件的完整路径,但Visual Studio 2005似乎不会这样做.这使得它比我应该解决我正在查看的解决方案的哪个分支更加尴尬(我知道的最快的方法是将鼠标悬停在选项卡上,以便将源文件的路径作为工具提示).
有没有办法让完整的解决方案或文件路径进入标题栏,或者至少在某个地方始终可见,这样我就能快速分辨出哪个分支被加载到每个实例中?
这是专为此工作量身定制的在线图库中的扩展.结帐http://erwinmayer.com/labs/visual-studio-2010-extension-rename-visual-studio-window-title/
没有本地方法可以做到这一点,但您可以使用宏来实现它.详细信息请参见此处:http://www.helixoft.com/blog/archives/32
您只需要在EvironmentEvents宏部分添加一点VB宏并重新启动VS.
注意:首次加载VS时,路径不会显示,但每当您更改正在查看的文件时,路径都会显示.可能有办法解决这个问题,但这似乎不是什么大问题.
查看最新版本的VSCommands 2010 Lite.它引入了一个名为Friendly Solution Name的功能,您可以在其中将其设置为在Visual Studio主窗口标题中显示解决方案文件路径(或其任何部分).更多细节:http://vscommands.com/releasenotes/3.6.8.0和http://vscommands.com/releasenotes/3.6.9.0
对于2008年,从上面接受的答案中编写宏的稍微好一点的方法是使用解决方案事件而不是文档事件 - 这使您可以随时编辑标题栏,即使您没有选择文档.这是宏我的同事和我基于另一个放在一起的你 - 你想要改变第15-18行来从源目录中提取您的分支名称,但是你已经设置好了.
01 Private timer As System.Threading.Timer 02 Declare Auto Function SetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpstring As String) As Boolean 03 04 Private _branchName As String = String.Empty 05 Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened 06 Try 07 If timer Is Nothing Then 08 ' Create timer which refreshes the caption because 09 ' IDE resets the caption very often 10 Dim autoEvent As New System.Threading.AutoResetEvent(False) 11 Dim timerDelegate As System.Threading.TimerCallback = _ 12 AddressOf tick 13 timer = New System.Threading.Timer(timerDelegate, autoEvent, 0, 25) 14 End If 15 Dim sourceIndex As Integer = DTE.Solution.FullName.IndexOf("\Source") 16 Dim shortTitle As String = DTE.Solution.FullName.Substring(0, sourceIndex) 17 Dim lastIndex As Integer = shortTitle.LastIndexOf("\") 18 _branchName = shortTitle.Substring(lastIndex + 1) 19 showTitle(_branchName) 20 Catch ex As Exception 21 22 End Try 23 End Sub 24 25 Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing 26 If Not timer Is Nothing Then 27 timer.Dispose() 28 End If 29 End Sub 30 31 32 '''Dispose the timer on IDE shutdown. 33 Public Sub DTEEvents_OnBeginShutdown() Handles DTEEvents.OnBeginShutdown 34 If Not timer Is Nothing Then 35 timer.Dispose() 36 End If 37 End Sub 38 39 '''Called by timer. 40 Public Sub tick(ByVal state As Object) 41 Try 42 showTitle(_branchName) 43 Catch ex As System.Exception 44 End Try 45 End Sub 46 47 '''Shows the title in main window. 48 Private Sub showTitle(ByVal title As String) 49 SetWindowText(New System.IntPtr(DTE.MainWindow.HWnd), title & " - " & DTE.Name) 50 End Sub