quinta-feira, 11 de setembro de 2008

Capturar a tela em um TBitmap

function CaptureScreenRect(ARect: TRect): TBitmap;
var ScreenDC: HDC;
begin
Result := TBitmap.Create;
with Result, ARect do
begin
Width := Right - Left;
Height := Bottom - Top;
ScreenDC := GetDC(0);
try BitBlt(Canvas.Handle,0,0,Width,Height,ScreenDC,Left,Top,SRCCOPY);
finally
ReleaseDC(0,ScreenDC);
end;
end;
end;

//Como usar:
//Image1.picture.Assign(CaptureScreenRect(Rect(0,0,Width,Height)));


Nenhum comentário: