unit PaintTest;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TfrmTest =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
FPaintBox: TPaintBox;
FTimer: TTimer;
FColor: TColor;
procedure DoOnPaint(Sender: TObject);
procedure DoOnTimer(Sender: TObject);
public
{ Public-Deklarationen }
end;
var
frmTest: TfrmTest;
implementation
{$R *.dfm}
{ TfrmTest }
function RandomColor: TColor;
begin
Result :=
RGB(Random($ff), Random($ff), Random($ff));
end;
procedure TfrmTest.DoOnPaint(Sender: TObject);
begin
FPaintBox.Canvas.Brush.Color := FColor;
FPaintBox.Canvas.FillRect(Rect(0, 0, FPaintBox.Width, FPaintBox.Height));
end;
procedure TfrmTest.DoOnTimer(Sender: TObject);
begin
FColor := RandomColor;
FPaintBox.Invalidate;
end;
procedure TfrmTest.FormCreate(Sender: TObject);
begin
FTimer := TTimer.Create(self);
FTimer.OnTimer := DoOnTimer;
FPaintBox := TPaintBox.Create(self);
FPaintBox.Parent := self;
FPaintBox.Align := alClient;
FPaintBox.OnPaint := DoOnPaint;
FColor := RandomColor;
end;
initialization
Randomize;
end.