unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TPanel =
class(ExtCtrls.TPanel)
// Wichtig, als erstes for TForm1
private
{ Private-Deklarationen }
FOnPaint: TNotifyEvent;
protected
{ Protected-Deklarationen }
procedure Paint;
override;
public
{ Public-Deklarationen }
property Canvas;
published
{ Published-Deklarationen }
property OnPaint: TNotifyEvent
read FOnPaint
write FOnPaint;
end;
type
TForm1 =
class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
procedure OnPanel1Paint(Sender: TOBject);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TPanel.Paint;
begin
inherited;
if assigned(fOnPaint)
then fOnPaint(Self);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Panel1.OnPaint := OnPanel1Paint;
end;
procedure TForm1.OnPanel1Paint(Sender: TOBject);
var r: Trect;
begin
r := Panel1.ClientRect;
InflateRect(r, -2, -2);
With Panel1
do
begin
Canvas.Brush.Color := clWindow;
Canvas.RoundRect(r.Left, r.Top, r.Right, r.Bottom, 20, 20);
Canvas.Brush.Color := Panel1.Color;
Canvas.Draw(5, 5, Application.Icon);
end;
end;
end.