截图屏幕部分图片

procedure TForm1.Button1Click(Sender: TObject);
var
    winHWND, hCur:integer;
    winDC:integer;
    rect:TRect;
    pt:TPoint;
    fBitmap:TBitmap;
    begin
    winHWND := GetDesktopWindow();
    winDC := GetDC(winHWND);
    GetWindowRect(winHWND, rect);
    fBitmap := TBitmap.create;
    fBitmap.width :=100;
    fBitmap.height := 50;
    BitBlt(fBitmap.canvas.handle, 0, 0, 100,50, winDC,500, 200, SRCCOPY); //截图
    ReleaseDC(winHWND, winDC);  //释放DC
    fBitmap.SaveToFile('c:/test1.bmp');
    Image1.Picture.Bitmap.Assign(fBitmap);  //将bitmap图片显示在image1中
    fBitmap.Free;
end;

你可能感兴趣的:(截图屏幕部分图片)