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.
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。