花褪残红青杏小。燕子飞时,绿水人家绕。

delphi之截取整个窗体图片

菜鸟编程 十五楼的鸟儿 20949浏览 0评论
很简单的代码,:-D
[code=delphi]
unit Unit1;

interface

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

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

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
bit: TBitmap;
begin
bit := TBitmap.Create;
bit.Width := Width;
bit.Height := Height;
BitBlt(bit.Canvas.Handle, 0, 0, Width, Height, GetWindowDC(Handle), 0, 0, SRCCOPY);{就是这里了,:-)}
bit.SaveToFile('c:\temp\Form1.bmp');{temp目录必须事先存在那里才行。}
bit.Free;
end;

end.[/code]

转载请注明:鸟儿博客 » delphi之截取整个窗体图片

游客
发表我的评论 换个身份
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址