1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,menus,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Button2: TButton;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Déclarations privées}
public
{ Déclarations publiques}
end;
var
Form1: TForm1;
CopieLeft, CopieTop, CopieWidth, CopieHeight:integer;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.width:=500;
Form1.height:=300;
Form1.color:=clwhite;
BorderStyle:=(bsToolWindow);
Button1.caption:='Copier';
Button1.left:=0;
Button1.top:=0;
Button1.width:=100;
Button1.height:=30;
Button1.visible:=true;
Button2.caption:='Effacer';
Button2.left:=110;
Button2.top:=0;
Button2.width:=100;
Button2.height:=30;
Button2.visible:=true;
Image1.width:=200;
Image1.height:=200;
Image1.left:=150;
Image1.top:=50;
Image1.visible:=true;
Image1.stretch:=true;
timer1.interval:=100;
timer1.enabled:=false;
{ Ceci défini la partie de l''écran qui sera copiée : }
CopieLeft:=0;
CopieTop:=0;
CopieWidth:=100;
CopieHeight:=100;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.visible:=false;
timer1.enabled:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Form1.Image1.canvas.Brush.Color := clwhite;
Form1.Image1.canvas.fillRect(Rect(0,0,CopieWidth,CopieHeight));
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
CL,CT:integer;
CopieBitMap:TBitMap;
begin
timer1.enabled:=false;
CL:=CopieLeft-Form1.left-4;
CT:=CopieTop-Form1.top-26;
CopieBitMap:= TBitmap.Create;
CopieBitMap.Width:=CopieWidth;
CopieBitMap.Height:=CopieHeight;
CopieBitMap.Canvas.CopyRect(rect(0,0,CopieWidth,CopieHeight),canvas,rect(CL,CT,CL+CopieWidth,CT+CopieHeight));
Form1.Image1.Picture.Bitmap:=CopieBitMap;
CopieBitMap.free;
Form1.visible:=true;
end;
end. |
Partager