Recent

Author Topic: TPaintbox picture disappears on resize  (Read 209 times)

Tommi

  • Full Member
  • ***
  • Posts: 236
TPaintbox picture disappears on resize
« on: April 30, 2025, 06:11:38 pm »
If I draw something inot TPaintBox.canvas, when I resize the form, or I reduce it to icon, the image disappears.

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
  paintbox1.Canvas.Pen.Color:=clYellow;
  paintbox1.Canvas.Pen.Width:=6;
  paintbox1.Canvas.Line(0,0,100,100);
end;

How could avoid it ?

(In attachment my minimal project)

Thank you.
« Last Edit: April 30, 2025, 06:17:31 pm by Tommi »

TRon

  • Hero Member
  • *****
  • Posts: 4351
Re: TPaintbox picture disappears on resize
« Reply #1 on: April 30, 2025, 06:31:33 pm »
If I draw something inot TPaintBox.canvas, when I resize the form, or I reduce it to icon, the image disappears.
Yes, that is how a paintbox (canvas) works.

Use the onpaint event to draw instead.
Today is tomorrow's yesterday.

 

TinyPortal © 2005-2018