unit Unit448;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.Classes, System.SysUtils,
Vcl.Forms,
Vcl.Controls,
Vcl.ExtCtrls,
Vcl.Graphics;
type
TForm448 =
class(TForm)
PaintBox1: TPaintBox;
procedure FormResize(Sender: TObject);
procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure PaintBox1Paint(Sender: TObject);
private
FBitmap: TBitmap;
function GetBitmap: TBitmap;
procedure WMEraseBkgnd(
var Message: TWmEraseBkgnd);
message WM_ERASEBKGND;
public
destructor Destroy;
override;
property Bitmap: TBitmap
read GetBitmap;
end;
var
Form448: TForm448;
implementation
{$R *.dfm}
destructor TForm448.Destroy;
begin
FBitmap.Free;
inherited Destroy;
end;
procedure TForm448.FormResize(Sender: TObject);
begin
Bitmap.SetSize(ClientWidth, ClientHeight);
end;
function TForm448.GetBitmap: TBitmap;
begin
if FBitmap =
nil then begin
FBitmap := TBitmap.Create;
end;
Result := FBitmap;
end;
procedure TForm448.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
Bitmap.Canvas.Brush.Color := clGray;
Bitmap.Canvas.FillRect(Rect(0, 0, Width, Height));
Bitmap.Canvas.TextOut(10, 10, FormatDateTime('
c', Now));
Bitmap.Canvas.MoveTo(0, Y);
Bitmap.Canvas.LineTo(Width, Y);
PaintBox1.Invalidate;
end;
procedure TForm448.PaintBox1Paint(Sender: TObject);
begin
BitBlt(Paintbox1.Canvas.Handle, 0, 0, Bitmap.Width, Bitmap.Height, Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
end;
procedure TForm448.WMEraseBkgnd(
var Message: TWmEraseBkgnd);
begin
Message.Result := 1;
end;
end.