Visual Studio的自动化:枚举打开的窗口时加载的解决方案 [英] Visual studio automation: Enumerate opened windows upon solution loading

查看:137
本文介绍了Visual Studio的自动化:枚举打开的窗口时加载的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

正如你可能知道,MSVS记得打开的文档,也就是当你加载的解决方案,IDE会载入previously打开的文件。我想要做的就是在解决方案加载执行与这些窗口的一些行动。

我试着在SolutionEvents_Opened处理程序来访问这些窗口。但有没有运气 - 看来,在目前SolutionEvents_Opened援引提到窗户都没有用。 DTE.Documents是空的,DTE.Windows.Items不包含他们。

我需要一些code,如:

 私人小组SolutionEvents_Opened()处理SolutionEvents.Opened
   昏暗窗口,窗口= DTE.Documents.Item(?)的Windows //打开的窗口之一
   ...
结束小组


解决方案

我发现枚举窗口的方法之一是在DocumentEvents.DocumentOpened事件,但它仅在一个解决方案的加载总是不触发它。它似乎并不认为SolutionEvents.Opened获取我的经验,否则静态变量可以在里面随意更改所有被解雇了。

<一个href=\"http://www.dotnetmonster.com/Uwe/Forum.aspx/vs-ext/1231/SolutionEvents-Opened-but-no-active-projects\"相对=nofollow>这可能有助于解释,虽然它。

How to enumerate opened code windows (i.e. those windows where you edit documents) upon solution loading using macros?

As you probably know, MSVS remembers opened documents, i.e. when you load solution, IDE will load previously opened files. What I want to do is to perform some actions with those windows upon solution loading.

I tried to access these windows in SolutionEvents_Opened handler. But have no luck - it seems that mentioned windows are not available at the moment SolutionEvents_Opened invoked. DTE.Documents is empty and DTE.Windows.Items doesn't contain them.

I need some code like:

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

解决方案

One way I've found to enumerate the window is on DocumentEvents.DocumentOpened event, but it fires it always and not only during the loading of a solution. It does not seem that the SolutionEvents.Opened gets fired at all in my experience otherwise a static variable could be changed in it.

This might help explain it though.

这篇关于Visual Studio的自动化:枚举打开的窗口时加载的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆