Visual studio shell 2010中跟踪当前选中的ToolWindow

来源:互联网 发布:unity3d实现物体闪烁 编辑:程序博客网 时间:2024/05/29 12:28

Step1:在VSpakage中实现IVsSelectionEvents接口;

Step2:在Initiliaze初始话函数中注册之:

IVsMonitorSelection ms = Package.GetGlobalService(typeof(IVsMonitorSelection)) as IVsMonitorSelection

if(ms != null)

{

ms.AdviseSelectionEvents(this, out cookie);
}


Step3:重点实现OnElementValueChanged方法;

1、elementid = Microsoft.VisualStudio.Shell.Interop.Constants.SEID_WindowFrame;

2、if(varNewValue is IVsWindowFrame) actvieWindowFrame = varNewValue as IVsWindowFrame;


Step4:通过FindToolWindow,查找当前的ToolWindow,比对其Frame字段是否与activeWindowFrame相等,若相当,则为当前选中的ToolWindow

0 0
原创粉丝点击