lzx838 发表于 2009-9-19 10:49:00

[分享]在CAD的帮助菜单栏增加下拉子菜单

本帖最后由 作者 于 2009-12-23 8:45:59 编辑

      
      static public void Cmd1()
      {
            Autodesk.Windows.RibbonMenuItem helpItem = new Autodesk.Windows.RibbonMenuItem();

            helpItem.Text = "我加的东东!!";// "My Help Item";
            helpItem.CommandHandler = new MyCommandHandler();
            Autodesk.Windows.RibbonMenuButton helpButton = Autodesk.Windows.ComponentManager.HelpButton;
            helpButton.Items.Insert(0, helpItem);
      }
    public class MyCommandHandler : System.Windows.Input.ICommand
    {
      public bool CanExecute(object parameter)
      {
            return true;
      }
      public event EventHandler CanExecuteChanged;
      public void Execute(object parameter)
      {
            System.Windows.Forms.MessageBox.Show("My Help Item got clicked");
      }
    }
程序要正常运行需要添加以下的引用:

现在上传源码工程文件:

运行环境:VS2008+AutoCAD2010

xiongdi6k 发表于 2020-4-2 11:53:39

回帖是一种美德!感谢楼主的无私分享 谢谢

yanghao1 发表于 2009-9-19 12:38:00

lzx838发表于2009-9-19 10:49:00static/image/common/back.gif49616                static public void Cmd1()      {   &    public class MyCommandHandler : System.Windows.Input.ICommand
    {
      public bool CanExecute(object parameter)
      {
            return true;
      }
      public event EventHandler CanExecuteChanged;
      public void Execute(object parameter)
      {
            System.Windows.Forms.MessageBox.Show("My Help Item got clicked");
      }
    }
需要引用CAD安装目录下的AdWindows.dll文件及Windows的WindowsBase
RibbonMenuItem 这个类找不到啊,是哪个组件的类

lzx838 发表于 2009-9-19 12:55:00

<p>引用CAD安装目录下的AdWindows.dll文件</p>

雪山飞狐_lzh 发表于 2009-9-19 15:25:00

Ribbon是AutoCad2009版本才有的,你的版本?

yanghao1 发表于 2009-9-19 18:47:00

lzh741206发表于2009-9-19 15:25:00static/image/common/back.gifRibbon是AutoCad2009版本才有的,你的版本?

<p>我本来引用的就有C:\ObjectARX 2009\inc-win32\AdWindows.dll,还是没有RibbonMenuItem这个类啊,怎么回事</p>

yanghao1 发表于 2009-9-19 18:52:00

lzh741206发表于2009-9-19 15:25:00static/image/common/back.gifRibbon是AutoCad2009版本才有的,你的版本?

<p>2009,2010的帮助文件中根本找不到这个类RibbonMenuItem,命名空间Autodesk.Windows我的项目里一直有,就是没有RibbonMenuItem类。</p>

雪山飞狐_lzh 发表于 2009-9-19 19:05:00

<p>AutoCad2010有的,注意在安装目录下引用</p><p>2009没用过,就不知道了</p>

yanghao1 发表于 2009-9-19 19:13:00

lzh741206发表于2009-9-19 19:05:00static/image/common/back.gifAutoCad2010有的,注意在安装目录下引用2009没用过,就不知道了

<p>对2010有RibbonMenuItem,但是为什么没有“helpButton.Items.Insert”中的Insert成员?看下面最后一句:</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; helpItem.Text = "我加的东东!!";// "My Help Item";<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; helpItem.CommandHandler = new MyCommandHandler();</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Autodesk.Windows.RibbonMenuButton helpButton = Autodesk.Windows.ComponentManager.HelpButton;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; helpButton.Items.Insert(0, helpItem);<br/></p>

雪山飞狐_lzh 发表于 2009-9-19 19:26:00

<p>1、确保你的目标项目为Framework3.0或以上</p><p>2、仔细看一楼最后一句话</p>

lzx838 发表于 2009-9-20 08:52:00

可惜我今天没上班,不然我把机子上的源码工程文件上传上来,大家就更明白更加清楚了.
页: [1] 2
查看完整版本: [分享]在CAD的帮助菜单栏增加下拉子菜单