S
sixeight
Unregistered / Unconfirmed
GUEST, unregistred user!
怎样在窗口上放TMyTest控件时,有这样的结构:
object MyTest: TMyTest
object MyC1: TMyC
end
object MyC2: TMyC
end
end
//代码
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes;
type
TMyTest = class;
TMyC = class(TComponent)
private
FFB: Integer;
FFA: String;
procedure SetFA(const Value: String);
procedure SetFB(const Value: Integer);
public
published
property FA: String read FFA write SetFA;
property FB: Integer read FFB write SetFB;
property Name;
end;
TMyList = class(TObject)
private
FList: TList;
FMyTest: TMyTest;
procedure SetMyTest(const Value: TMyTest);
function GetCount: Integer;
protected
public
constructor Create(ATest: TMyTest);
destructor Destroy; override;
property MyTest: TMyTest read FMyTest write SetMyTest;
published
property Count: Integer read GetCount;
end;
TMyTest = class(TComponent)
private
FMyList: TMyList;
procedure SetMyList(const Value: TMyList);
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property MyList: TMyList read FMyList write SetMyList;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Long', [TMyTest]);
RegisterNoICON([TMyC]);
end;
{ TMyTest }
constructor TMyTest.Create(AOwner: TComponent);
begin
inherited;
FMyList := TMyList.Create(Self);
end;
destructor TMyTest.Destroy;
begin
FMyList.Free;
inherited;
end;
procedure TMyTest.SetMyList(const Value: TMyList);
begin
FMyList := Value;
end;
{ TMyList }
constructor TMyList.Create(ATest: TMyTest);
begin
FList := TList.Create;
FMyTest := ATest;
end;
destructor TMyList.Destroy;
begin
FList.Free;
inherited;
end;
function TMyList.GetCount: Integer;
begin
Result := FList.Count;
end;
procedure TMyList.SetMyTest(const Value: TMyTest);
begin
FMyTest := Value;
end;
{ TMyC }
procedure TMyC.SetFA(const Value: String);
begin
FFA := Value;
end;
procedure TMyC.SetFB(const Value: Integer);
begin
FFB := Value;
end;
end.
TMyC该怎样创建?(没分了)
object MyTest: TMyTest
object MyC1: TMyC
end
object MyC2: TMyC
end
end
//代码
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes;
type
TMyTest = class;
TMyC = class(TComponent)
private
FFB: Integer;
FFA: String;
procedure SetFA(const Value: String);
procedure SetFB(const Value: Integer);
public
published
property FA: String read FFA write SetFA;
property FB: Integer read FFB write SetFB;
property Name;
end;
TMyList = class(TObject)
private
FList: TList;
FMyTest: TMyTest;
procedure SetMyTest(const Value: TMyTest);
function GetCount: Integer;
protected
public
constructor Create(ATest: TMyTest);
destructor Destroy; override;
property MyTest: TMyTest read FMyTest write SetMyTest;
published
property Count: Integer read GetCount;
end;
TMyTest = class(TComponent)
private
FMyList: TMyList;
procedure SetMyList(const Value: TMyList);
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property MyList: TMyList read FMyList write SetMyList;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Long', [TMyTest]);
RegisterNoICON([TMyC]);
end;
{ TMyTest }
constructor TMyTest.Create(AOwner: TComponent);
begin
inherited;
FMyList := TMyList.Create(Self);
end;
destructor TMyTest.Destroy;
begin
FMyList.Free;
inherited;
end;
procedure TMyTest.SetMyList(const Value: TMyList);
begin
FMyList := Value;
end;
{ TMyList }
constructor TMyList.Create(ATest: TMyTest);
begin
FList := TList.Create;
FMyTest := ATest;
end;
destructor TMyList.Destroy;
begin
FList.Free;
inherited;
end;
function TMyList.GetCount: Integer;
begin
Result := FList.Count;
end;
procedure TMyList.SetMyTest(const Value: TMyTest);
begin
FMyTest := Value;
end;
{ TMyC }
procedure TMyC.SetFA(const Value: String);
begin
FFA := Value;
end;
procedure TMyC.SetFB(const Value: Integer);
begin
FFB := Value;
end;
end.
TMyC该怎样创建?(没分了)