unit Panel1;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls;type
TPanel1 = class(TPanel)
private
FShape1: TShape;
FShape2: TShape;
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Shape1: TShape read FShape1 write FShape1;
property Shape2: TShape read FShape2 write FShape2;
end;procedure Register;implementationconstructor TPanel1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FShape1 := TShape.Create(self);
FShape2 := TShape.Create(self);
end;destructor TPanel1.Destroy;
begin
FShape1.Free;
FShape2.Free;
inherited Destroy;
end;procedure Register;
begin
RegisterComponents('System', [TPanel1]);
end;end.以上代码不能在Panel 上显示出Shape1和Shape2,为什么?
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls;type
TPanel1 = class(TPanel)
private
FShape1: TShape;
FShape2: TShape;
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Shape1: TShape read FShape1 write FShape1;
property Shape2: TShape read FShape2 write FShape2;
end;procedure Register;implementationconstructor TPanel1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FShape1 := TShape.Create(self);
FShape2 := TShape.Create(self);
end;destructor TPanel1.Destroy;
begin
FShape1.Free;
FShape2.Free;
inherited Destroy;
end;procedure Register;
begin
RegisterComponents('System', [TPanel1]);
end;end.以上代码不能在Panel 上显示出Shape1和Shape2,为什么?
解决方案 »
- delphi hide无法隐藏子窗体
- 求一段配置文件代码
- 有人用DELPHI来写过可以让JAVA来调用的dll文件吗?
- 在线等关于timer定时扫描数据库时,程序无响应的问提!!
- 关于Wb Services的安全问题:怎样做到只有授权用户可以访问?
- 我想用delphi开发一个数据库系统,要求数据库十分稳定,又没有版权的纠纷,请问应选择哪种数据库!
- 关于窗口的DOCK
- 我是用DELPHI的,已经习惯了DELPHI,想学JAVA!高手给点建议,好吗!
- 有人用过powersock中的capturefile过程吗?
- VB调用Delphi写的动态库乱码
- ????高分求助,在线等待!???
- 到哪里能下载DELPHI7???给个地址好吗?
begin
inherited Create(AOwner);
FShape1 := TShape.Create(self);
FShape2 := TShape.Create(self);
FShape1.parent := panel1;
FShape2.parent := panel1;end;
FShape1.Parent:=Self;
FShape2 := TShape.Create(self);
FShape2.Parent:=Self;
其一、没有指定 TShape.Parent 属性;
FShape1.Parent := Self;
FShape2.Parent := Self;
其二、没有指定他们的 BoundsRect 属性,也就是没有指定他们的位置和大小;
with FShape1 do
begin
Left := 10;
Top := 10;
Width := 30;
Height := 30;
end;
with FShape2 do
begin
Left := 60;
Top := 10;
Width := 30;
Height := 30;
end;
或者:
FShape1.SetBounds(10, 10, 30, 30);
FShpae2.SetBounds(60, 10, 30, 30);