Why can't I force a PaintBox to redraw?

Why can't I force a PaintBox to redraw?

Post by Alan » Fri, 03 Aug 2007 02:04:31



I've got a PaintBox that I'm drawing on. When the user changes the font size (through a menu selection) I want to redraw the graphic to reflect the change. I've tried everything I can think of:

pbchart.refresh;
pbchart.Repaint;
pbchart.Invalidate;
pbchart.Canvas.Refresh;

Nothing makes it repaint.

Thanks for any help.
 
 
 

Why can't I force a PaintBox to redraw?

Post by Jens Grusc » Fri, 03 Aug 2007 02:08:02

> Nothing makes it repaint.

Use MyPaintBox.Invalidate and make all your drawings your the
MyPaintBox.OnPaint event handler. You should never draw to a TPaintBox
from outside this event handler. If you need a control that "remembers"
previous drawings use a TImage with a TBitmap (at the cost of more
memory usage). Of course you can also use a TBitmap internally which you
paint to your TPaintBox.Canvas in its OnPaint event handler.

--
Jens Gruschel
http://www.yqcomputer.com/