[Lazarus] Paintbox complete redraw
Howard Page-Clark
hdpc at talktalk.net
Wed Sep 24 00:14:56 CEST 2008
Benito van der Zander wrote:
> is there a way to change the whole paintbox in the OnPaint event?
> For example, if I draw this in Onpaint:
> PaintBox1.Canvas.brush.Color:=rgb(random(255),random(255),random(255));
> PaintBox1.Canvas.Rectangle(0,0,100,100);
> and move another window in XP over the paintbox it is striped instead of
> being filled with a single color.
When the window covering PaintBox1 is removed, the operating system repaints only the newly exposed region, which your code fills
with a (new) randomly generated colour. Unless by chance that new colour happens to coincide with the previous Paintbox colour it
will look like exactly what you have coded for: a randomly coloured stripe.
If you replace
rgb(random(255),random(255),random(255))
with
rgb(100, 100, 100)
you'll not notice the repainting because it will be painted in the same indistinguishable colour as before (well, there might be
some flicker).
Howard
More information about the Lazarus
mailing list