unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
TKlasse =
class(TGraphicControl)
public
procedure DoSomething;
end;
TErbe1 =
class(TKlasse)
protected
procedure Paint;
override;
end;
TErbe2 =
class(TKlasse)
protected
procedure Paint;
override;
end;
var
Form1: TForm1;
Klasse: TKlasse;
implementation
{$R *.dfm}
{ TKlasse }
procedure TKlasse.DoSomething;
begin
Paint;
end;
{ TErbe1 }
procedure TErbe1.Paint;
begin
inherited;
with Canvas
do
begin
Brush.Color := clRed;
Rectangle(10, 10, 80, 80);
end;
end;
{ TErbe2 }
procedure TErbe2.Paint;
begin
inherited;
with Canvas
do
begin
Brush.Color := clGreen;
Ellipse(10, 10, 80, 80);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Klasse := TErbe1.Create(Self);
with Klasse
do
begin
Parent := Self;
Top := 50;
Left := 50;
Height := 100;
Width := 100;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Klasse.DoSomething;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Klasse.Free;
end;
end.