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
|
type
TForm1 = class(TForm)
Panel1: TPanel;
Image1: TImage;
Image2: TImage;
procedure FormCreate(Sender: TObject);
procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Déclarations privées }
autorisation:boolean;
xs,ys,imleft,imtop,nbimage,indice:integer;
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i:integer;
begin
xs:=x;
ys:=y;
for i:=1 to 2 do //pour 2 Timages par exemple( tu en mets autant que tu veux)
if ptinrect(rect(Timage(Findcomponent('image'+inttostr(i))).left,Timage(Findcomponent('image'+inttostr(i))).top,Timage(Findcomponent('image'+inttostr(i))).left+Timage(Findcomponent('image'+inttostr(i))).width,Timage(Findcomponent('image'+inttostr(i))).top+Timage(Findcomponent('image'+inttostr(i))).height),point(x,y)) then
begin
imleft:=Timage(Findcomponent('image'+inttostr(i))).Left;
imtop:=Timage(Findcomponent('image'+inttostr(i))).Top;
indice:=i;
autorisation:=true;
end;
end;
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if autorisation then
begin
panel1.DoubleBuffered:=true;
Timage(Findcomponent('image'+inttostr(indice))).Left:=imleft+x-xs;
Timage(Findcomponent('image'+inttostr(indice))).top:=imtop+y-ys;
caption:='('+inttostr(x)+','+inttostr(y)+')';
end;
end;
procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
autorisation:=false;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
image1.Enabled:=false;
image2.Enabled:=false;
end;
end. |
Partager