By the time honoured method of reverse engineering the existing VC# project item wizards, I have built a custom wizard for adding a new item to an existing C# project.
The custom wizard is available from the Add New Item dialog, but I was wondering if it was possible to add it to the project's context menu in the solution explorer How would this be accomplished, and is it also possible to add a sibmenu
Thanks,
Andrew.

Add Custom wizard to context menu?
Fish Fish
Andrew.
Gothmordrin
Hi Andrew,
The easiest thing to do would be to build an addin, and programatically add a new menu/command to the Project.Add popup menu.
I don't think named commands would work for you, as named commands are used to support delay loading the addin, meaning your addin's IDTCommandTarget.QueryStatus wouldn't be invoked until the addin was loaded into the IDE.
I would probably do something similar to the code below. The addin will have to be loaded in order to support the menu item, but you can easily display or hide it based on the type of project currently selected, but handling the SelectionEvents.OnChange similar to the sample below.
An alternative (and probably more work than you're looking for) would be to use build a VSIP package that adds additional menus to the Project.Add context menu, and use the VISIBILITY_SECTION of the .CTC resource to control visibility of the menu item, based on the active commandUI guids. There's been some recent newsgroup posts on this topic over in the microsoft.public.vstudio.extend newsgroup.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Office.Core;
using Extensibility;
using EnvDTE;
[GuidAttribute("B8DB81D0-EDE6-4B91-858F-E737EDCB26E6"), ProgId("ProjMenu.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
public Connect()
{
btnLaunchMyWizard = null;
}
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
{
applicationObject = (_DTE)application;
addInInstance = (AddIn)addInInst;
if (btnLaunchMyWizard == null)
{
try
{
Object objMissing = System.Reflection.Missing.Value;
CommandBarPopup cmdBarPopup = (CommandBarPopup) applicationObject.CommandBars["Project"].Controls["A&dd"];
btnLaunchMyWizard = (CommandBarButton)cmdBarPopup.Controls.Add(MsoControlType.msoControlButton, objMissing, objMissing, 1, true);
btnLaunchMyWizard.Caption = "&My Wizard";
btnLaunchMyWizard.FaceId = 1845;
btnLaunchMyWizard.Click +=new _CommandBarButtonEvents_ClickEventHandler(btnLaunchMyWizard_Click);
selectionEvents = applicationObject.Events.SelectionEvents;
selectionEvents.OnChange +=new _dispSelectionEvents_OnChangeEventHandler(selectionEvents_OnChange);
}
catch(Exception e)
{
Debug.WriteLine(e.Message);
}
}
}
public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom){}
public void OnAddInsUpdate(ref System.Array custom){}
public void OnStartupComplete(ref System.Array custom){}
public void OnBeginShutdown(ref System.Array custom){}
private void selectionEvents_OnChange()
{
if (applicationObject.SelectedItems.Count==1)
{
Project proj = applicationObject.SelectedItems.Item(1).Project;
if (proj != null)
{
if (proj.Kind == VSLangProj.PrjKind.prjKindCSharpProject)
btnLaunchMyWizard.Visible = true;
else
btnLaunchMyWizard.Visible = false;
}
}
}
private void btnLaunchMyWizard_Click(CommandBarButton Ctrl, ref bool CancelDefault)
{
/* todo: call applicationObject.LaunchWizard(). */
}
private _DTE applicationObject;
private AddIn addInInstance;
private CommandBarButton btnLaunchMyWizard;
private SelectionEvents selectionEvents;
}
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.