13.3. Solution
Now that you've seen the code generator in action, you will see how it works behind the scenes in this section. To add your own custom "wizards" to the Add New Item dialog in Visual Studio, you create a new Class Library project and add a class that implements the IDTWizard interface. The full definition of the IDTWizard interface can be found at http://msdn.microsoft.com/en-us/library/envdte.idtwizard.execute.aspx.
The IDTWizard interface is in the EnvDTE namespace, which is an assembly wrapped COM library containing the objects that enable you to manipulate the Visual Studio Design Time Environment. The interface has only one method, Execute, which is called when the wizard is launched using the Add New Item or Add New Project menu items. The method signature for the Execute method is as follows:
public void Execute(object Application, int hwndOwner, ref object[] ContextParams, ref object[] CustomParams, ref wizardResult retval)
The parameters are defined as follows:
Application: A dispatch pointer to the highest-level automation object for the Visual Studio environment
hwndOwner: The hWnd handle for the parent of the wizard's window
ContextParams: An array of elements that varies according to whether your wizard is launched from the Add Items or the New Project dialog. The following table describes which options are available depending on which type of wizard you are creating.
Wizard Type Parameters Used New Project WizardType, ProjectName, LocalDirector, InstallationDirectory, ...
Get ASP.NET 3.5 Enterprise Application Development with Visual Studio® 2008: Problem - Design - Solution now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.