日期:2014-05-18  浏览次数:20924 次

开发VS2008插件怎么添加菜单项
已经在VS中按向导生成了插件代码,要怎么样才能在用户右击文档弹出的菜单(有重构、组织using等)里加入自己的项目,并制作响应方法?

除此以外,如何添加工具条和按钮?

希望有代码,谢谢!

------解决方案--------------------
C# code

if(poWatchContextMenu == null)
                {
                    _CommandBars commandBars = Application.CommandBars; 
                    CommandBar vsBarProject =  Application.CommandBars["Code Window"];
                    poWatchContextMenu = vsBarProject.Controls.Add(MsoControlType.msoControlButton, 1, "", 1, true);
                    poWatchContextMenu.Caption = "My Watch";
                    poWatchContextMenu.TooltipText = "";
                    CommandBarEvents menuItemHandler = (CommandBarEvents)Application.DTE.Events.get_CommandBarEvents(poWatchContextMenu);
                    menuItemHandler.Click += new _dispCommandBarControlEvents_ClickEventHandler(Watch_Click); 
                
                }

------解决方案--------------------
路过,,,学习