图形显示在Image1中,你将它放在剪贴板中就行了。
//Joe
//******************
//下面的代码抓矩形:
function CaptureScreen(const Rect: TRect; const BitDepth: TPixelFormat =
pfDevice): TBitmap;
var
hDC: Windows.HDC;
hDesktop: THandle;
begin
// create and define the bitmap
Result := Graphics.TBitmap.Create;
try
case BitDepth of
pfCustom, pfDevice:
Result.PixelFormat := pfDevice;
else
Result.PixelFormat := BitDepth;
end;
Result.Width := Rect.Right - Rect.Left;
Result.Height := Rect.Bottom - Rect.Top;
hDesktop := GetDeskTopWindow();
hDC := GetDC(hDesktop);
try
BitBlt(Result.Canvas.Handle, 0, 0, Result.Width, Result.Height, hDC,
Rect.Left, Rect.Top, SRCCOPY);
finally
ReleaseDC(hDesktop, hDC);
end;
except
FreeAndNil(Result);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
bmp: TBitmap;
rect: TRect;
begin
rect.TopLeft := Panel1.ClientToScreen(Panel1.ClientRect.TopLeft);
rect.BottomRight := Panel1.ClientToScreen(Panel1.ClientRect.BottomRight);
bmp := CaptureScreen(rect);
Image1.Picture.Bitmap := bmp;
end;