右击f1book时出现工作簿设计器,可以直接在这里对工作簿进行编辑,这是怎么做到的呢?我也在控件中想实现这样的功能,而且编辑后的结果要显示在控件中,要怎么做呢?请不吝赐教!

解决方案 »

  1.   

    其实就是像fast report双击控件会出现报表设计器一样(——这是怎么做到的呢?)只是f1book是可视控件,所以编辑结果还要显示在控件中
    能帮我看看吗?
      

  2.   

    我研究了一下fastreport,发现它是在这里定义的,细节的东西还需要再研究
      TfrRepEditor = class(TComponentEditor)
        procedure ExecuteVerb(Index: Integer); override;   
        function GetVerb(Index: Integer): String; override;
        function GetVerbCount: Integer; override;
      end;
      

  3.   

    TComponentEditor provides the default implementation for the IComponentEditor interface.UnitDesignEditorsDescriptionUse TComponentEditor or one of its descendants as a base class when defining a design-time editor for working with a new component class. Although you can create component editors that descend directly from TBaseComponentEditor, it is convenient to use TComponentEditor, because this classs supplies a default implementation of the IComonentEditor interface.Create a new component editor class for a component class to add verbs to its context menu, change its default double-click behavior, or allow the component to use a new clipboard format. Once the component editor is defined, it can be registered to work with a particular component class.  A registered component editor is created for each component of that class when it is selected in the form designer.  When the component is double-clicked, the Edit method of the component editor is called.  When the user right-clicks the component, the GetVerbCount and GetVerb methods of the editor are called to build context menu. To create the association between a component editor and a component class, call RegisterComponentEditor.Delphi provides a descendant of TComponentEditor (TDefaultEditor) which all components use if they have no registered association with a component editor.
      

  4.   

    好象就是控件的控件编辑器吧,看看我些的那个连载文章的最后一骗中可能有你要的
    http://www.csdn.net/develop/read_article.asp?id=20251
    http://www.csdn.net/develop/read_article.asp?id=20252
    http://www.csdn.net/develop/read_article.asp?id=20262
    http://www.csdn.net/develop/read_article.asp?id=20263
      

  5.   

    function GetVerbCount: Integer; override;//定义了右键菜单中内容的数量
    function GetVerb(Index: Integer): String; override;//定义了对应右键菜单中第index个(从0开始)的内容
    你定义了上面两个函数,控键的右键菜单中会自动添加进去。
    procedure ExecuteVerb(Index: Integer); override; //定义了对应菜单中响应的事件,在这里调用报表设计器,其实报表设计器也是一个类,设计窗体的显示是在报表设计器这个类中实现的
      

  6.   

    非常感谢两位!
    接下来我该自己试一试了,希望遇到问题的时候还能得到你们的帮助!
    //bow