把你的procedure改成:procedure name(sender:Tobject);就可以在对象管理齐里看到了!
解决方案 »
- Delphi怎么样格式化memo里面的数据
- dataset中用sql语句as出来的列,如何赋值?
- listview画背景的问题
- 如何显示指定窗体名的窗体
- 请教:fastreport分页问题
- 怎样用tapi实现WINDOWS“传入的连接”的功能?
- 怎样手动设定DBGrid中每一列的宽度?
- Delphi入门书推荐???
- 如何能控制edit.txt里的内容,例如我只允许用户输入整型数字
- 我的头大了。。。。。。。。。。。。。。
- 我是sybase新手,以前使用oracle,我现在遇到一个问题,就是在sybase中怎样将字符型转化为数字型?我知道convert函数,却不知道具体的格式
- 谁知道Tparaser这类的用法?
然后 用publish 字段 发表
一个记录
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;不知是否为你所需
过程指针是没问题的。
只要你根据不同的过程定义相应的过程指针即可,然后在
初始化过程中把你的过程指针赋值.
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就好了。
你问的东东应该也是挺常用的。
同意Lighterwang(lighterwang),
这答案应该就是你想要的吧?
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.