フォーム・カスタマー・エリアの画像をファイルまたはクリップ・ボードに保存

1362 ワード


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Clipbrd; { }

// 
procedure TForm1.Button1Click(Sender: TObject);
var
  bit: TBitmap;
begin
  bit := TBitmap.Create;
  bit := Self.GetFormImage;
  bit.SaveToFile('c:\temp\img1.bmp');
  bit.Free;
end;

// 
procedure TForm1.Button2Click(Sender: TObject);
begin
  Self.GetFormImage.SaveToFile('c:\temp\img2.bmp');
end;

// 
procedure TForm1.Button3Click(Sender: TObject);
var
  Format: Word;
  Data: Cardinal;
  APalette: HPALETTE;
begin
  {TBitmap.SaveToClipboardFormat  ,  }
  GetFormImage.SaveToClipboardFormat(Format, Data, APalette);
  { }
  Clipboard.SetAsHandle(Format, Data);
end;

end.