views:

291

answers:

1

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
+1  A: 

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.

Mladen Mihajlovic