procedure TForm1.Button1Click(Sender: TObject);//已经包含了Classes
var
PEditor:^TEdit;
Editors:TList;
begin
ExpNum:=10;
Editors:=TList.Create;
New(PEditor);
PEditor^.Parent:=Form1;
PEditor^.Top:=20;
PEditor^.Width:=60;
PEditor^.Height:=50;
PEditor^.Left:=40;
Editors.Add(PEditor);
Edit1.Text:=IntToStr(Editors.Count);
Editors.Free;
Dispose(PEditor);
end;请问为什么我一加上Peditor的一些属性(如:Peditor^.parent:=form1)就编译不过去了?
var
PEditor:^TEdit;
Editors:TList;
begin
ExpNum:=10;
Editors:=TList.Create;
New(PEditor);
PEditor^.Parent:=Form1;
PEditor^.Top:=20;
PEditor^.Width:=60;
PEditor^.Height:=50;
PEditor^.Left:=40;
Editors.Add(PEditor);
Edit1.Text:=IntToStr(Editors.Count);
Editors.Free;
Dispose(PEditor);
end;请问为什么我一加上Peditor的一些属性(如:Peditor^.parent:=form1)就编译不过去了?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
PEditor:^TEdit;
Editors:TList;
begin
Editors:=TList.Create;
New(PEditor);
PEditor^.Parent:=Form1;
PEditor^.Top:=20;
PEditor^.Width:=60;
PEditor^.Height:=50;
PEditor^.Left:=40;
Editors.Add(PEditor);
Editors.Free;
Dispose(PEditor);
end;end.
var
PEditor:TEdit;
Editors:TList;
begin
Editors:=TList.Create;
PEditor:=TEdit.Create(nil);
PEditor.Parent:=Form1;
PEditor.Top:=20;
PEditor.Width:=60;
PEditor.Height:=50;
PEditor.Left:=40;
Editors.Add(PEditor);
Editors.Free;
end;
以上代码没测试,不过应该是这样的。