Hallo,
warum sollte ein Panel keinen Canvas besitzen?
Delphi-Quellcode:
type
TMyPanel =
class (TPanel)
protected
procedure Paint;
override;
end;
//procedure TPanel.Paint;
procedure TMyPanel.Paint;
var
R : TRect;
i : Integer;
b : Byte;
begin
inherited;
R := ClientRect;
AdjustClientRect (R);
for i := R.Left
to R.Right - 1
do
begin
b := Trunc(255 * (i - R.Left) / (R.Right - 1 - R.Left));
Canvas.Pen.Color :=
RGB(0, 144, b);
Canvas.MoveTo (i, 0);
Canvas.LineTo (i, Height);
end;
end;
Gruß Hawkeye
//Edit: Methoden-Header korrigiert, Dank an Sunlight7!