unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
FBuffer: TBitMap;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Timer1.Enabled := False;
FBuffer.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FBuffer := TBitMap.Create;
FBuffer.Width := PaintBox1.Width; //1280
FBuffer.Height := PaintBox1.Height; //720
Timer1.Enabled := True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
FBuffer.Canvas.Brush.Color := clWhite;
FBuffer.Canvas.FillRect(FBuffer.Canvas.ClipRect);
FBuffer.Canvas.Brush.Color := clGreen;
FBuffer.Canvas.Rectangle(20, 20, 100, 100);
BitBlt(PaintBox1.Canvas.Handle, 0, 0, PaintBox1.Width, PaintBox1.Height, FBuffer.Canvas.Handle, 0, 0, SRCCOPY);
end;
end.