Click here to Skip to main content
Click here to Skip to main content

Close the Start Page Add-In for Visual Studio

, 26 Mar 2009
Rate this:
Please Sign up or sign in to vote.
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".

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

Next, only select Microsoft Visual Studio:

Give a good description of your Add-in:

Set your Add-in to load on Startup:

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.

    //
    // 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;

    // 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.

/// <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)

About the Author

EricFaust
Web Developer National Research Corporation
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 Pinmemberpvandijk2831-Mar-09 21:00 
GeneralRe: My Vote of 4 PinmemberEricFaust1-Apr-09 5:38 
GeneralMy vote of 2 PinmemberAvi_Harush30-Mar-09 21:21 
GeneralRe: My vote of 2 PinmemberMember 192044118-Apr-09 2:55 
GeneralRe: My vote of 2 PinmemberEricFaust24-Apr-09 11:50 
GeneralMy vote of 1 PinmemberPriyank Bolia28-Mar-09 18:39 
GeneralRe: My vote of 1 PinmemberEricFaust30-Mar-09 3:33 
NewsOr you could just check the options dialog... PinmemberMember 300191026-Mar-09 13:41 
GeneralRe: Or you could just check the options dialog... PinmemberMichael.F.Starke26-Mar-09 16:13 
GeneralRe: Or you could just check the options dialog... PinmemberEricFaust26-Mar-09 16:38 

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

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

| Advertise | Privacy | Mobile
Web01 | 2.8.140718.1 | Last Updated 26 Mar 2009
Article Copyright 2009 by EricFaust
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid