rbWiki > RCL > Fundamentals > How To...Use the PaintBox Component

How To...Use the PaintBox Component

Table of contents
  1. 1. Question 
  2. 2. Solution

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;
Tags
none

Files (0)

 
You must login to post a comment.