Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-09

Paintbox complete redraw

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Benito van der Zander

Hi,
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.

Benito

Reply by email

Howard Page-Clark
to Benito van der Zander
Benito van der Zander wrote 6 lines
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

Reply by email

Bogusław Brandys
to Howard Page-Clark

Howard Page-Clark pisze:

Show quoted text 23 lines
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 ____________

What is the cause of flicker ? I see it is common problem in Lazarus for all controls under Windows ?
did you found the reason ?

Boguslaw

Reply by email

Howard Page-Clark
to Bogusław Brandys
Boguslaw Brandys wrote
What is the cause of flicker ? I see it is common problem in Lazarus for all controls under Windows ? did you found the reason ?

I don't know, but presume flickering controls get painted successively rather than just once. I know various Lazarus graphics routines have recently had a major rewrite, and the evolution and testing is continuing. The results on Windows seem less satisfactory than on unix at the moment. This is the joy of using a tool that is continually being improved, and (I imagine - I'm not clever enough to be one myself) the headache of being a developer where the improvements you introduce in one part of a complex codebase give rise to unwanted or unforeseen side effects elsewhere. Software is imperfect, but Lazarus is much less imperfect than a year or two ago. I can only congratulate its developers on their skill and teamwork, and ability to overcome their disagreements and blend all their insights into a first rate, free tool.

Howard

Reply by email