I currently have a visual studio add-in and have created a new output window pane which I can write text to successfully. However, when the output window is not open or it is minimised then it doesn't open (popup) when I call the Activate() method on the pane. Any ideas how I can achieve this?
- 1I'd say it isn't typically very appropriate for an add-in to automatically switch windows. Leave it up to the user.Hans Passant– Hans Passant2010-10-15 16:35:10 +00:00Commented Oct 15, 2010 at 16:35
- @Hans - It might be useful in a case similar to a Find where, after the search, the results window is given focus and you want to direct the user's attention there. No?shaunmartin– shaunmartin2010-10-15 16:41:12 +00:00Commented Oct 15, 2010 at 16:41
- @Hans what if his add-in magically does all your work?Yuriy Faktorovich– Yuriy Faktorovich2010-10-15 16:41:13 +00:00Commented Oct 15, 2010 at 16:41
- 1Its for displaying the results from a build server and so I would think it would be appreciated if the user was shown the results. Similar to the Build results which are displayed when a local build is run in VS. I still expect the user to develop their solution themselves ;o)gouldos– gouldos2010-10-15 17:23:25 +00:00Commented Oct 15, 2010 at 17:23
Add a comment |
1 Answer
If you created your Add-in using the Add-in wizard you should have an Exec() method like below. I have added two lines that cause the Output window to open and become visible regardless whether it was originally closed or minimized. I tested this in VS2008 and VS2010.
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if(commandName == "AddinTest.Connect.AddinTest") { // Find the output window. Window outputWindow = _applicationObject.Windows.Item(Constants.vsWindowKindOutput); // Show the window. (You might want to make sure outputWindow is not null here...) outputWindow.Visible = true; handled = true; return; } } } 1 Comment
Yann Duran
This was useful in a VSPackage as well, so thanks for that. It was driving me crazy! The code needs to be modified slightly, to use _dte.Windows instead of _applicationObject.