Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Captura de pantalla en un Bitmap (https://www.clubdelphi.com/foros/showthread.php?t=80536)

Neftali [Germán.Estévez] 30-06-2006 10:13:23

Captura de pantalla en un Bitmap
 
¿Cómo se puede capturar la pantalla en un bitmap?

Sobre un formulario, coloca un TImage y un TButton. Copia el siguiente código:

Código Delphi [-]
procedure ScreenShot (Image : TBitmap);
var
  DC : HDC;

begin
  DC := GetDC (GetDesktopWindow);
  // Proteccion para liberar
  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;

Para utilizarlo puedes usar éste código en el OnClick del Botón:

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
  ScreenShot(Image1.Picture.Bitmap);
end;


La franja horaria es GMT +2. Ahora son las 21:36:12.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi