dte.Solution.SolutionBuild.StartupProjects 改变时是否有事件触发? [英] Is there an event triggered when dte.Solution.SolutionBuild.StartupProjects changes?
问题描述
我正在构建一个 Visual Studio 2010 插件供我公司内部使用.我想自定义主窗口标题以显示当前启动项目的名称.我可以使用以下代码设置主窗口的标题:
I am building a visual studio 2010 Add-in for internal use in my company. I would like to customize the main window caption to display the name of the current start up project. I can set the caption of the main window with the following code:
DTE d = GlobalClass.dte2 as DTE;
IntPtr hWnd = new System.IntPtr(d.MainWindow.HWnd);
if (d.Solution.SolutionBuild.StartupProjects != null)
{
object[] sStartUpProject = (object[])d.Solution.SolutionBuild.StartupProjects;
string Caption = d.MainWindow.Caption + "Current Project: " + (string)sStartUpProject[0];
SendMessage(hWnd, WM_SETTEXT, new IntPtr(0), Caption);
}
每当创建或激活窗口时,我都可以触发此代码,但是如果用户更改解决方案资源管理器(或我的加载项)中的启动项目并且没有移动到另一个窗口,这不会更新标题视觉工作室.我希望在做出更改后立即更新标题.
I can fire this code whenever a window is created or activated, but this does not update the Caption if the user changes the startup project in the solution explorer (or my add-in) and doesn't move to another window in Visual Studio. I would like the caption to update as soon as the change was made.
推荐答案
是的,您需要订阅 IVsMonitorSelection
事件并处理 OnElementValueChanged()
SEID_StartupProject
代码>.
Yes, you need subscribe to IVsMonitorSelection
events and handle SEID_StartupProject
in OnElementValueChanged()
.
看看这段代码,它是不言自明的:
Check out this code, it's quite self-explaining:
这篇关于dte.Solution.SolutionBuild.StartupProjects 改变时是否有事件触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!