怎样在动态生成的控件数组中区分触发事件的控件?(50分)

  • 主题发起人 主题发起人 programsky
  • 开始时间 开始时间
P

programsky

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure tform1.neimage(h,w:integer);
var newimage:array[1..200] of Timage;
begin
newimage[10*w+h]:=timage.create(self);
with newimage[10*w+h] do begin
parent:=self;
tag:=h+w;
Width:=39;
Height:=50;
top:=50*h+8;
left:=39*w+10;
onclick:=imgonclick;
end;
end;
怎样在imgonclick过程中区别不同的image控件
 
procedure tform1.neimage(h,w:integer);
var newimage:array[1..200] of Timage;
begin
newimage[10*w+h]:=timage.create(self);
with newimage[10*w+h] do begin
parent:=self;
tag:=h+w;
Width:=39;
Height:=50;
top:=50*h+8;
left:=39*w+10;
onclick:=imgonclick;
end;
end;


//---------------------------------------------------------------------
procedure tform1.imgonclick(sender:TObject);
begin
//tag is your Image controls' Index
//For Example
TImage(Sender).Picture.LoadFromFile('c:/Pics/A/'+inttostr(TImage(Sender).tag)+'.bmp');
//Then you can load diffrent picture according your Image's Index
end;
//-------------------------------------------------------------------------
 
同意楼上观点.
 

Similar threads

I
回复
0
查看
771
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
508
import
I
后退
顶部