{put this declaration in your interface section}function PrintWindow(SourceWindow: hwnd; Destination: hdc; nFlags: cardinal): bool; stdcall; external 'user32.dll' name 'PrintWindow';本函数在delphi里面好像没有定义。。。只有自己加咯。。。procedure TForm1.Button1Click(Sender: TObject);
var
bmp : TBitmap;
wnd : cardinal;
rec : TRect;
begin
wnd := FindWindow('TScreenRecurF', nil); // get the handle
// of your window
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);
Image1.Picture.Assign(bmp);
finally
bmp.Free;
end;
end;
说明,本函数可以可以截取窗体可见属性不是hide且不是最小化的窗体内容,不管该窗体是否被其他窗体遮盖、是否在屏幕位置。