How To…Use the PaintBox Component

Question

“How is the PaintBox component meant to be used?”

Solution

The PaintBox component is a report control that can be used to draw directly to a Canvas. Use the TppPaintBox.Canvas property to draw text, lines, images, etc. Use the OnPrint event to draw to the canvas. The example below shows how the TppPaintBox component might be used to create shapes and text that might otherwise be impossible using other report components.

Download: PaintBox.zip

Sample Delphi code:

begin
  ppPaintBox1.Canvas.MoveTo(100, 100);
  ppPaintBox1.Canvas.LineTo(200, 100);

  ppPaintBox1.Canvas.Font.Name := 'Arial';
  ppPaintBox1.Canvas.Font.Size := 12;
  ppPaintBox1.Canvas.TextOut(100, 80, 'Hello Paintbox!');

end;