兄弟,这是我从TPanel继承下来的一个东东,没有实际价值,但
是可以为你排忧解难,新加入了一个Items属性。
type
tpanel1 = class(tpanel)
private
{ Private declarations }
PItems : TStrings;
procedure SetPItems(Value : TStrings);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner : TComponent);override;
destructor Destroy;override;
published
{ Published declarations }
property Items : TStrings read PItems write SetPItems;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [tpanel1]);
end;
constructor TPanel1.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
PItems := TStringList.Create; //TStrings为虚类,所以实现时
//要用TStringList
end;
destructor TPanel1.Destroy;
var
I : integer;
begin
for I := 0 to PItems.Count - 1 do begin
TPanel(PItems.Objects).Free;
end;
PItems.Free;
inherited Destroy; //Free不行!
end;
procedure TPanel1.SetPItems(Value : TStrings);
begin
PItems.Assign(Value); //不能写PItems := Value
end;
给分?