Главная страница | назад





Article #16277: Creating temporary canvas

 Question and Answer Database
FAQ1277D.txt Creating temporary canvas
Category :VCL
Platform :All
Product :All 32 bit
Question:
I need a temporary canvas to draw to, but when I attempt to
create one, I get several application errors. How do I do this?
Answer:
Create a Bitmap, and use the TBitmap's canvas property to
draw on. The following example creates a Bitmap, draw on its'
canvas, draws the canvas to the form's backgound, and then
free the bitmap.
Example:
procedure TForm1.Button1Click(Sender: TObject);
var
bm : TBitmap;
begin
bm := TBitmap.Create;
bm.Width := 100;
bm.Height := 100;
bm.Canvas.Brush.Color := clRed;
bm.Canvas.FillRect(Rect(0, 0, 100, 100));
bm.Canvas.MoveTo(0, 0);
bm.Canvas.LineTo(100, 100);
Form1.Canvas.StretchDraw(Form1.ClientRect,
Bm);
bm.Free;
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99