unit ImageLabelTEST;
interface
uses
System.SysUtils, System.Classes,
Vcl.Controls,
Vcl.StdCtrls,
Vcl.ExtCtrls,
Vcl.Graphics,
Vcl.Forms;
type
TMyImage =
class(TImage)
private
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
property Picture;
property Visible;
end;
TMyLabel =
class(TLabel)
private
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
property Caption;
property Visible;
end;
TImageLabelTEST =
class(TCustomControl)
private
FImage: TMyImage;
FLabel: TMyLabel;
function GetImage: TPicture;
procedure SetImage(
const Value: TPicture);
function GetLabelCaption: TCaption;
procedure SetLabelCaption(
const Value: TCaption);
function GetLabelFont: TFont;
procedure SetLabelFont(
const Value: TFont);
protected
procedure Resize;
override;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
property aImage: TMyImage
read FImage;
property aLabel: TMyLabel
read FLabel;
published
// folgende properties würde ich gerne mit den properties aus den eigenen Subkomponenten ersetzen
property I_Picture: TPicture
read GetImage
write SetImage;
property L_Caption: TCaption
read GetLabelCaption
write SetLabelCaption;
property L_Font: TFont
read GetLabelFont
write SetLabelFont;
property Align;
property Anchors;
property Visible;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
TRM', [TImageLabelTEST]);
end;
{ TMyImage }
constructor TMyImage.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
destructor TMyImage.Destroy;
begin
Self.Free;
inherited Destroy;
end;
{ TMyLabel }
constructor TMyLabel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
destructor TMyLabel.Destroy;
begin
Self.Free;
inherited Destroy;
end;
{ TImageLabel }
constructor TImageLabelTEST.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FImage := TMyImage.Create(Self);
FImage.Parent := Self;
FImage.Align := alTop;
FImage.Height := 100;
FLabel := TMyLabel.Create(Self);
FLabel.Parent := Self;
FLabel.Align := alClient;
FLabel.Alignment := taCenter;
end;
procedure TImageLabelTEST.Resize;
begin
inherited;
end;
function TImageLabelTEST.GetImage: TPicture;
begin
Result := FImage.Picture;
end;
procedure TImageLabelTEST.SetImage(
const Value: TPicture);
begin
FImage.Picture.Assign(Value);
end;
function TImageLabelTEST.GetLabelCaption: TCaption;
begin
Result := FLabel.Caption;
end;
procedure TImageLabelTEST.SetLabelCaption(
const Value: TCaption);
begin
FLabel.Caption := Value;
end;
function TImageLabelTEST.GetLabelFont: TFont;
begin
Result := FLabel.Font;
end;
procedure TImageLabelTEST.SetLabelFont(
const Value: TFont);
begin
FLabel.Font.Assign(Value);
end;
destructor TImageLabelTEST.Destroy;
begin
FImage.Free;
FLabel.Free;
inherited Destroy;
end;
end.