我在工具菜单中有一个菜单项,但它需要进入文件->新菜单,但是即使在预生成的 Visual Studio 代码中将“工具”更改为“文件”也不会产生预期的结果!!! ?
Tom J Nowell
问问题
1030 次
3 回答
1
您还需要更改 eventlistner 代码。检查代码顶部的自动生成的代码段。
于 2009-03-17T11:00:25.047 回答
1
以下代码(不是防弹的!)在 Addin OnConnection 方法中对我来说很好:
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
if (connectMode == ext_ConnectMode.ext_cm_UISetup)
{
object[] contextGUIDS = new object[] { };
Commands2 commands = (Commands2)_applicationObject.Commands;
CommandBars commandBars = (CommandBars)_applicationObject.CommandBars;
CommandBar menuBarCommandBar = commandBars["MenuBar"];
CommandBarPopup filePopup = menuBarCommandBar.Controls["File"] as CommandBarPopup;
CommandBarPopup newPopup = filePopup.CommandBar.Controls["New"] as CommandBarPopup;
Command command = commands.AddNamedCommand2(_addInInstance, "MyAddin1", "MyAddin1",
"Executes the command for MyAddin1", true, 59, ref contextGUIDS,
(int)(vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled),
(int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
if (command != null && newPopup != null)
{
command.AddControl(newPopup.CommandBar, 1);
}
}
于 2009-03-17T11:01:00.130 回答
1
您是否尝试过在命令行运行 devenv.exe /resetaddin Your.AddIn.Name(例如 devenv.exe /resetaddin MyAddin1.Connect)?
于 2009-03-17T12:08:34.133 回答