unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject); private
{ Private declarations }
procedure mpress(Sender:Tobject);//////////这里总报错!!!!!
public { Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure mpress(sender:Tobject);
begin
showmessage('asdf');
end;procedure TForm1.Button1Click(Sender: TObject);
var
my:Tbutton;
begin
my:=Tbutton.Create(self);
my.Width:=10;
my.Top :=10;
my.Parent :=form1;
my.OnClick :=unit1.Form1.mpress ;end;
end.[Error] Unit1.pas(18): Unsatisfied forward or external declaration: 'TForm1.mpress'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'谢谢大家了!
self 和 nil 有什么区别啊?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject); private
{ Private declarations }
procedure mpress(Sender:Tobject);//////////这里总报错!!!!!
public { Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure mpress(sender:Tobject);
begin
showmessage('asdf');
end;procedure TForm1.Button1Click(Sender: TObject);
var
my:Tbutton;
begin
my:=Tbutton.Create(self);
my.Width:=10;
my.Top :=10;
my.Parent :=form1;
my.OnClick :=unit1.Form1.mpress ;end;
end.[Error] Unit1.pas(18): Unsatisfied forward or external declaration: 'TForm1.mpress'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'谢谢大家了!
self 和 nil 有什么区别啊?
create(nil)是指Parent是Nil, 此时, 必须用Free来释放, 否则一直在内存中.
begin
showmessage('asdf');
end;
begin
showmessage('asdf');
end;