通过m_toolWindow1的关闭按钮关闭窗口,然后再执行如下代码: foreach (EnvDTE.Window win in _ApplicationObject.Windows) { this._OutputWindowPane.OutputString(string.Format("{0}—{1}",win.Caption,win.Visible)+ Environment.NewLine); }
发现m_toolWindow1 仍旧存在,只是Visible = false了。
另:我通过在OnConnect方法中截获WindowEvents,但是我发现以上m_toolWindow1 窗口并未触发 winEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(this.WindowActivated); winEvents.WindowClosing += new _dispWindowEvents_WindowClosingEventHandler(this.WindowClosing); winEvents.WindowCreated += new _dispWindowEvents_WindowCreatedEventHandler(this.WindowCreated); winEvents.WindowMoved += new _dispWindowEvents_WindowMovedEventHandler(this.WindowMoved);