views:

55

answers:

2

While I'm perfectly willing to believe that this has been asked elsewhere, I haven't been able to find it.

I'm currently using macros to switch window layouts in Visual Studio by importing .vssettings files, but these files don't maintain the maximized state of the IDE (I have a single-screen layout that I want to be maximized, and a dual-screen layout that shouldn't be). I'd like to alter the two macros that load these settings to maximize or restore the IDE window, but so far I haven't been able to find a way to do this.

So, for the actual question: how can I maximize or restore the Visual Studio (2008) IDE window programmatically via macros?

+1  A: 

Can you catch the WindowCreated Event from the WindowEvents object and set the Window to Maximized state?

Private Sub WindowEvents_WindowCreated(ByVal Window As EnvDTE.Window) Handles WindowEvents.WindowCreated
    Window.WindowState = vsWindowState.vsWindowStateMaximize
End Sub
Jacob G
While I didn't need to catch the event (I want to apply it at the time that I apply the window style, so I'm already executing code), somehow I managed to miss the `WindowState` property. Thanks!
Adam Robinson
+1  A: 

This did it for me:

    DTE.MainWindow().WindowState = vsWindowState.vsWindowStateMaximize
Bahbar