【问题标题】:Visual studio automation: Enumerate opened windows upon solution loadingVisual Studio 自动化:在加载解决方案时枚举打开的窗口
【发布时间】:2010-09-08 12:30:08
【问题描述】:

如何在使用宏加载解决方案时枚举打开的代码窗口(即编辑文档的窗口)?

您可能知道,MSVS 会记住打开的文档,即当您加载解决方案时,IDE 会加载以前打开的文件。我想要做的是在解决方案加载时对这些窗口执行一些操作。

我尝试在 SolutionEvents_Opened 处理程序中访问这些窗口。但是没有运气 - 似乎在调用 SolutionEvents_Opened 时提到的窗口不可用。 DTE.Documents 为空且 DTE.Windows.Items 不包含它们。

我需要一些代码,例如:

Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened
   Dim window As Window = DTE.Documents.Item(?).Windows // one of the opened windows
   ...
End Sub

【问题讨论】:

    标签: vb.net visual-studio scripting automation


    【解决方案1】:

    我发现枚举窗口的一种方法是在 DocumentEvents.DocumentOpened 事件上,但它总是会触发它,而不仅仅是在加载解决方案期间。根据我的经验,SolutionEvents.Opened 似乎根本没有被触发,否则可能会在其中更改静态变量。

    This 可能有助于解释它。

    【讨论】:

      猜你喜欢
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-05
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      相关资源
      最近更新 更多