Click here to Skip to main content
15,881,173 members
Articles / Programming Languages / C#

Close the Start Page Add-In for Visual Studio

Rate me:
Please Sign up or sign in to vote.
4.16/5 (16 votes)
26 Mar 2009CPOL2 min read 32.9K   97   10   10
A custom Add-In to close the Start Page in Visual Studio after you open your project

Introduction

This is a simple Visual Studio add-in that will automatically close the Start page when you open your solution in Visual Studio.

I love Visual Studio and the Start Page but why there isn't an option to close the Start Page after you open your solution is beyond me. And if you ever need to re-open the Start Page, simply go to the "View" menu and select "Other Windows" and click "Start Page".

Using the Code

To build this application from scratch go into Visual Studio and select "New" Project. Then browse to "Other Project Types\Extensibility" and select "Visual Studio Add-in". Then name your project "StartPageCloser".

Image 1

Next the Add-in Wizard will start and for this project, we will select C# code:

Image 2

Next, only select Microsoft Visual Studio:

Image 3

Give a good description of your Add-in:

Image 4

Set your Add-in to load on Startup:

Image 5

The About dialog box is optional. Then Click finish to start your new Add-in project.

Here is where you will need to add your code. Start by adding the private variables needed to capture the Open Solution event.  You can add this code at the top or the bottom of the Connect class. You should already be in the Connect class, if not then open the Connect.cs file.

C#
//
// Private variables used to capture the Solution events
//
private Events2 events;
private SolutionEvents solutionEvents;

Next go to the "OnConnection" event function and add the following code after the line:
_addInInstance = (AddIn)addInInst;

C#
// Capture our Events
events = (Events2)_applicationObject.Events;
solutionEvents = events.SolutionEvents;

// Capture our Solution Opened Event
solutionEvents.Opened +=
new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);

Finally all you need to do is add your SolutionEvents_Opened function.

C#
/// <summary>
/// Our Solution has been opened
/// </summary>
private void SolutionEvents_Opened()
{
	// Find the Start Page and Close it
	if (_applicationObject.Windows.Item
		(EnvDTE80.WindowKinds.vsWindowKindKindStartPage) != null)
	{
		// Close the Start Page
		_applicationObject.Windows.Item
			(EnvDTE80.WindowKinds.vsWindowKindKindStartPage).Close
			(vsSaveChanges.vsSaveChangesNo);
	}
}

You are now ready to compile and use your new Add-in.  After you compile, the Add-in will be added to your Visual Studio Addins folder.  This will point to the location of your Add-in DLL.  Feel free to change your project to "Release" mode when you are done.

Points of Interest

Sometimes, in order to compile your add-in you will need to close Visual Studio and make sure that it is not set to load your add-in on Startup by going to the "Tools" menu and "Add-in Manager..." and un-checking "Startup" for your add-in. Then close and re-open Visual Studio and open your project. Now you will be able to compile. Just remember to go back in and re-check "Startup" when you are done.

History

  • 26th March, 2009: Initial post 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead ABILITY Network Inc
United States United States
Began writing software at the age of 10.
Graduated from the University of Houston in 1995 with a BS in Computer Science and a minor in Math.
I love developing great software and websites.
I recently moved to Seattle and I'm currently working for a Health Care Analytics company.

Hobbies include Basketball and Soccer and very happily married to a wonderful wife.

Comments and Discussions

 
GeneralMy Vote of 4 Pin
pvandijk2831-Mar-09 21:00
professionalpvandijk2831-Mar-09 21:00 
GeneralRe: My Vote of 4 Pin
EricFaust1-Apr-09 5:38
EricFaust1-Apr-09 5:38 
GeneralMy vote of 2 Pin
Avi_Harush30-Mar-09 21:21
Avi_Harush30-Mar-09 21:21 
GeneralRe: My vote of 2 Pin
jean80it18-Apr-09 2:55
jean80it18-Apr-09 2:55 
GeneralRe: My vote of 2 Pin
EricFaust24-Apr-09 11:50
EricFaust24-Apr-09 11:50 
GeneralMy vote of 1 Pin
Priyank Bolia28-Mar-09 18:39
Priyank Bolia28-Mar-09 18:39 
GeneralRe: My vote of 1 Pin
EricFaust30-Mar-09 3:33
EricFaust30-Mar-09 3:33 
NewsOr you could just check the options dialog... Pin
Member 300191026-Mar-09 13:41
Member 300191026-Mar-09 13:41 
GeneralRe: Or you could just check the options dialog... PinPopular
Michael.F.Starke26-Mar-09 16:13
Michael.F.Starke26-Mar-09 16:13 
GeneralRe: Or you could just check the options dialog... Pin
EricFaust26-Mar-09 16:38
EricFaust26-Mar-09 16:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.