[Lazarus] Paintbox complete redraw
Howard Page-Clark
hdpc at talktalk.net
Wed Sep 24 20:18:04 CEST 2008
Benito van der Zander wrote:
> So how can you redraw the paintbox complete in OnPaint?
This is a hack, so I hope another may show you how to do it properly.
Add a boolean flag to your form class thus:
type
TForm1 = class( TForm )
...
private
FOnPaintCalled: boolean;
...
end;
and a Formcreate event handler to initialise FOnPaintCalled:
PROCEDURE Tform1 .Formcreate ( Sender : Tobject ) ;
BEGIN
inherited;
FOnPaintCalled := false;
End;
and write the OnPaint handler as follows:
PROCEDURE Tform1 .Paintbox1paint ( Sender : Tobject ) ;
BEGIN
PaintBox1.Canvas.brush.Color:=rgb( random(255), random(255), random(255) );
PaintBox1.Canvas.Rectangle(0, 0, 100, 100);
if not FOnPaintCalled then Paintbox1.Invalidate;
FOnPaintCalled := not FOnPaintCalled;
End;
Regards
Howard
More information about the Lazarus
mailing list