我用的是delphi7.0代码如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
split:TSplitter;begin
split:=TSplitter.create(form1);
end;end.提示出错信息如下:
[Error] Unit1.pas(27): Undeclared identifier: 'TSplitter'
[Error] Unit1.pas(30): Missing operator or semicolon
[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'
注:TSplitter是分隔条;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
split:TSplitter;begin
split:=TSplitter.create(form1);
end;end.提示出错信息如下:
[Error] Unit1.pas(27): Undeclared identifier: 'TSplitter'
[Error] Unit1.pas(30): Missing operator or semicolon
[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'
注:TSplitter是分隔条;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ExtCtrls
;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
split:TSplitter;begin
Try
split:=TSplitter.create(form1);
Finally
split.Free;
split:=nil;
end;
end;
end.
我觉的办法是:
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
split:TSplitter;
{ Private declarations }
public
{ Public declarations }
end;
...............
procedure TForm1.Button1Click(Sender: TObject);
begin
split:=TSplitter.create(self);
split.parent:=self;
end;
uses里不用加extctrls
建议的形式:
组件.create;
try
.........
finally
组件.free
end;