hixiaosheng 发表于 2010-3-16 11:44

delphi截屏

unit Unit1;

interface

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

type
TForm1 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
function PrintWindow(SourceWindow: hwnd; Destination: hdc; nFlags: cardinal): bool; stdcall; external 'user32.dll' name 'PrintWindow';
implementation
{$R *.dfm}



procedure TForm1.btn1Click(Sender: TObject);
var
bmp : TBitmap;
wnd : Integer;
rec : TRect;
begin
wnd := FindWindow(nil, 'QQ2010');
GetWindowRect(wnd, rec);
bmp := TBitmap.Create;
try
bmp.Width := rec.Right - rec.Left;
bmp.Height := rec.Bottom - rec.Top;
bmp.PixelFormat := pf24bit;
PrintWindow(wnd, bmp.Canvas.Handle, 0);
bmp.SaveToFile('qq.jpg');
finally
bmp.Free;
CloseHandle(wnd);
end;
end;
end.

秋风夜雪 发表于 2010-3-19 23:36

没看懂!!

orange86630 发表于 2010-3-20 16:47

Delphi一直看不懂。。。
等我把vb学会了再学吧

zchld 发表于 2010-3-24 22:19

想学 有点太深奥了
页: [1]
查看完整版本: delphi截屏