unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure foto_pantalla(Image: TBitmap);
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.foto_pantalla(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);
var
Image_m: Timage;
begin
Image_m:= TImage.Create(Self);
foto_pantalla(Image_m.Picture.Bitmap);
Image_m.Picture.SaveToFile('imagen.bmp');
Image_m.Free;
end;
end.