H
hxliu
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
procedure rproc(sender:tobject);
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn2Click(Sender: TObject);
var m:tmethod;
begin
m.Code:=@rproc; <---出错语句,为什么不行
m.data:=bitbtn1;
bitbtn1.OnClick:=tnotifyevent(m);
end;
procedure TForm1.rproc(sender: tobject);
begin
showmessage('this is a test');
end;
end.
//另外:如果我的过程名是一个字符型变量,程序又该怎么写。
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
procedure rproc(sender:tobject);
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn2Click(Sender: TObject);
var m:tmethod;
begin
m.Code:=@rproc; <---出错语句,为什么不行
m.data:=bitbtn1;
bitbtn1.OnClick:=tnotifyevent(m);
end;
procedure TForm1.rproc(sender: tobject);
begin
showmessage('this is a test');
end;
end.
//另外:如果我的过程名是一个字符型变量,程序又该怎么写。