unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
 ScreenDC:HDC;
begin
 ScreenDC := GetDC(0);
 Rectangle(ScreenDC, 10, 10, 200, 200);
 ReleaseDC(0,ScreenDC);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
 Canvas:TCanvas;
 ScreenDC:HDC;
begin
 ScreenDC := GetDC(0);
 Canvas:=TCanvas.Create();
 Canvas.Handle:=ScreenDC;
 Image1.Canvas.Copyrect(Rect(0,0,Image1.Width,Image1.Height),Canvas,
        Rect(0,0,Screen.Width,Screen.Height));
 ReleaseDC(0,ScreenDC);
 Canvas.Free;
end;

end.
