witam, mam mały problem (szukałem ale nie znalazłem więc piszę temat), mianowicie w zdarzeniu OnClick chciałbym sprawdzić który komponent został kliknięty (Image) i wyswietlic info za pomocą ShowMessage, ponadto jak za pomocą tych pobranych danych można by było zmodyfikować np przesunąć dany obrazek, proszę o pomoc
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, JPEG;
type
TForm1 = class(TForm)
procedure OnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TNewImg = class(TImage)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
tabl: array[0..2] of TNewImg;
x: integer;
implementation
{$R *.dfm}
procedure TForm1.OnClick(Sender: TObject);
begin
ShowMessage('');
tabl[x].Picture.LoadFromFile('C:\0.jpg');
tabl[x].Left:=0;
tabl[x].Top:=250;
Form1.Refresh;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.DoubleBuffered:=True;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
tabl[0]:=TNewImg.Create(self);
tabl[0].Parent:=Form1;
tabl[0].Name:='tabl0';
tabl[0].Picture.LoadFromFile('C:\1.jpg');
tabl[0].Left:=0;
tabl[0].Top:=0;
tabl[0].Width:=320;
tabl[0].Height:=200;
tabl[0].Stretch:=True;
tabl[0].OnClick:=OnClick;
tabl[1]:=TNewImg.Create(self);
tabl[1].Parent:=Form1;
tabl[1].Name:='tabl1';
tabl[1].Picture.LoadFromFile('C:\2.jpg');
tabl[1].Left:=500;
tabl[1].Top:=0;
tabl[1].Width:=320;
tabl[1].Height:=200;
tabl[1].Stretch:=True;
tabl[1].OnClick:=OnClick;
end;
end.