unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.StdCtrls;
type
TPanel =
class(
Vcl.ExtCtrls.TPanel)
private
FLabel: TLabel;
protected
procedure Paint;
override;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
end;
TForm1 =
class(TForm)
Panel1: TPanel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TPanel }
constructor TPanel.Create(AOwner: TComponent);
var
MyRect: TRect;
begin
inherited;
FLabel := TLabel.Create(Self);
FLabel.Parent := Self;
MyRect := Self.ClientRect;
FLabel.Left := MyRect.Width
div 2;
FLabel.Top := MyRect.Height
div 2;
FLabel.Width := 50;
FLabel.Height := 17;
FLabel.Caption := '
Hello World';
end;
destructor TPanel.Destroy;
begin
inherited;
end;
procedure TPanel.Paint;
var
MyRect: TRect;
begin
inherited;
MyRect := Self.ClientRect;
MyRect.Inflate(-10, -10, -10, -10);
Self.Canvas.Brush.Color := clSilver;
Self.Canvas.Ellipse(MyRect.Left, MyRect.Top, MyRect.Right, MyRect.Bottom);
end;