unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
ScrollBox1: TScrollBox;
Image1: TImage;
Panel1: TPanel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure GetScreen(var bmp: TBitmap);
var
dc : integer;
c : TCanvas;
R : TRect;
begin
bmp := TBitmap.Create;
dc := GetWindowDC(0);
try
c := TCanvas.Create;
c.Handle := dc;
R := Rect(0, 0, Screen.Width, Screen.Height);
bmp.Width := R.Right;
bmp.Height := R.Bottom;
bmp.Canvas.CopyRect(R, c, R);
c.Handle := 0;
c.Free;
finally
ReleaseDC(0, dc);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
bmp: TBitmap;
begin
bmp := TBitmap.Create;
GetScreen(bmp);
Image1.Picture.Bitmap.Assign(bmp);
end;
end.