unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.ExtCtrls;
type
TForm1 =
class(TForm)
PaintBox1: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
bmp: TBitmap;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
bmp := TBitmap.Create;
bmp.Canvas.Brush.Color := clred;
bmp.Canvas.Pen.Width := 3;
bmp.Width := Paintbox1.Width;
bmp.Height := Paintbox1.Height;
bmp.Canvas.Rectangle(5,5, 75, 75);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
bmp.Free;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
bmp.Width := Paintbox1.Width;
bmp.Height := Paintbox1.Height;
PaintBox1.Repaint;
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
BitBlt(PaintBox1.Canvas.Handle, 0, 0, bmp.Width, bmp.Height, bmp.Canvas.Handle,
0, 0, SrcCopy);
end;
end.