把你的procedure改成:procedure name(sender:Tobject);就可以在对象管理齐里看到了!

解决方案 »

  1.   

    var pp: procedure f1;
    然后 用publish 字段 发表
      

  2.   

    请先定义一个类:TProcedure = Procedure;
    一个记录
    TProRecord=
      Procedurename:String;
      Pro:TProcedure;
    end;
    procedure f1;
    begin
      showmessage('f1');
    end;
    procedure f2;
    begin
      showmessage('f2');
    end;var
      v:array [1..3] of TRecord;
    begin
      v[1].procedurename='f1';
      v[1].pro=f1;
      v[1].pro; // show 'f1'
    ....
    end;不知是否为你所需
      

  3.   

    在记录类型中过程名这个域在赋值时写死,别的方法待研究
    过程指针是没问题的。
    只要你根据不同的过程定义相应的过程指针即可,然后在
    初始化过程中把你的过程指针赋值.
    1 : TSelfProcedure = Procedure of Object;
    2 :  TSelfRecord = Record
           ProdName : String;
           FProd       : TSelfProcedure;
         end;
    3 :  srProcedure : TSelfRecord;
    4 :  srProcedure.ProdName := 'P1';
         srProcedure.FProd := P1;
    这里不用改你写的变态的过程体,哈哈!
    在调用P1时只要用srProcedure.FProd就好了。
      

  4.   

    wd2306 (木头):
    你问的东东应该也是挺常用的。
    同意Lighterwang(lighterwang),
    这答案应该就是你想要的吧?
      

  5.   

    不是,我自己写了一个,大家看看!
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      Menus, StdCtrls,typinfo;type
      TForm1 = class(TForm)
        Button1: TButton;
        MainMenu1: TMainMenu;
        file1: TMenuItem;
        open1: TMenuItem;
        close1: TMenuItem;
        edit1: TMenuItem;
        cut1: TMenuItem;
        procedure Button1Click(Sender: TObject);
        procedure open1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    type
      map1=record
         functionname:string;
         Pfucntion:pointer;
         end;
    var
      Form1: TForm1;
      functioncount:integer;
      maparray: array [0..10]of map1;
      methodarray:array [0..10] of Tmethod;
    implementation
     uses  unit2;
    {$R *.DFM}procedure f1;
    begin
    showmessage('f1 procedure');
    end;
    procedure f2;
    begin
    showmessage('f2 procedure');
    end;
    procedure f3;
    begin
    showmessage('f3 procedure');
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      i,j:integer;
    begin
       form2.Show;
       //form2.StringGrid1.Cells[1,1]:='why';
       j:=1;
      for i:=0 to componentcount-1 do
          if Ispublishedprop(components[i],'onclick')
             then
             begin
             form2.StringGrid1.Cells[0,j]:=components[i].name;
             j:=j+1;
             end;
    end;procedure TForm1.open1Click(Sender: TObject);
    begin
    showmessage('openclick');
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      maparray[0].functionname:='f1';
      maparray[1].functionname:='f2';
      maparray[2].functionname :='f3';
      maparray[0].Pfucntion:=@f1;
      maparray[1].Pfucntion:=@f2;
      maparray[2].Pfucntion:=@f3;end;end.unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, Grids,typinfo;type
      TForm2 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        StringGrid1: TStringGrid;
        procedure FormCreate(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    var
      Form2: TForm2;implementation
    uses unit1;
    {$R *.DFM}procedure TForm2.FormCreate(Sender: TObject);
    begin
    StringGrid1.Cells[0,0]:='class';
    StringGrid1.cells[1,0]:='action';
    end;procedure TForm2.Button1Click(Sender: TObject);
    var
      i,j:integer;
    begin
      for i:=0 to 2 do
       begin
       methodarray[i].Code:=maparray[i].Pfucntion ;
       methodarray[i].Data:=nil;
       end;
      for i:=0 to form1.ComponentCount-1 do
       for j:=0 to 2 do
         begin
         if  (stringgrid1.Cells[1,i+1]=maparray[j].functionname) then
               SetMethodProp(form1.components[i+1],'onclick',methodarray[j]);
         end;
         form2.close;
    end;procedure TForm2.Button2Click(Sender: TObject);
    begin
    form2.close;
    end;end.