Capturing the Screen to a Bitmap


Capturing the Screen to a Bitmap

procedure ScreenShot (Image : TBitmap);
var
  DC : HDC;
begin
  DC := GetDC (GetDesktopWindow);
  try
    Image.Width  := GetDeviceCaps (DC, HORZRES);
    Image.Height := GetDeviceCaps (DC, VERTRES);
    BitBlt(Image.Canvas.Handle, 0, 0, Image.Width,
      Image.Height,DC, 0, 0, SRCCOPY);
  finally
    ReleaseDC (GetDesktopWindow, DC);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ScreenShot(Image1.Picture.Bitmap);
end;
http://www.alexnolan.nildram.co.uk