要实现动态创建10个(或更多)tshape控件,然后把所有的shape的onmousedowm事件都指向一个函数,怎么做,下面的为什么不行
procedure TForm1.Button1Click(Sender: TObject);
var
sp:array[0..10]of Tshape;
begin
sp[0]:=Tshape.Create(self);
sp[0].Left:=0;
sp[0].Top:=0;
sp[0].Width:=30;
sp[0].Height:=10;
sp[0].Shape:=stRoundSquare;
sp[0].Visible:=true;
sp[0].Show;end;
procedure TForm1.Button1Click(Sender: TObject);
var
sp:array[0..10]of Tshape;
begin
sp[0]:=Tshape.Create(self);
sp[0].Left:=0;
sp[0].Top:=0;
sp[0].Width:=30;
sp[0].Height:=10;
sp[0].Shape:=stRoundSquare;
sp[0].Visible:=true;
sp[0].Show;end;
解决方案 »
- 怎样用代码来调节windows的虚拟内存?
- 请推荐一本delphi图形图像编程方面的好书(在线)
- 关于软件看门狗的问题,大家一起探讨一下
- 2个关于面向对象的问题? 请大家讨论一下!
- 吐血求救 ,2000中如何使用 NetSessionEnum 函数来取得 当前访问 本机的网络用户的信息?
- 这条SqL怎么写?
- 小问题,为什么增加不行呢?
- 如何从excel表中读取数据 倒入到sql server中?
- 数据输入的问题,我都要烦死了,快帮帮我!!求你们了。
- 如何在Delphi编的程序中列出所有的数据库,谢谢
- 刚学delphi关于Tlistbox组件的问题.本论坛已搜索过没有找到答案
- 关于动态创建组件的问题?、/
var
sp:array[0..10]of Tshape;
begin
sp[0]:=Tshape.Create(self);
sp[0].Left:=0;
sp[0].Top:=0;
sp[0].Width:=30;
sp[0].Height:=10;
sp[0].Shape:=stRoundSquare;
sp[0].Parent:=self ;end;
var
sp:array[0..9]of Tshape; i:integer;
begin
for i:=0 to 9 do
begin
sp[i]:=Tshape.Create(self);
sp[0].Parent:=self ;
sp[i].Left:=//位置自己调;
sp[i].Top:=//位置自己调;
sp[i].Width:=30;
sp[i].Height:=10;
sp[i].Shape:=stRoundSquare;
end;
end;
Y: Integer);
begin
Caption := IntToStr(X) + ';' + IntToStr(Y);
end;procedure TForm1.Button1Click(Sender: TObject);
var
sp:array[0..10]of Tshape;
begin
sp[0]:=Tshape.Create(self);
sp[0].Parent:=self ;
sp[0].Left:=0;
sp[0].Top:=0;
sp[0].Width:=30;
sp[0].Height:=10;
sp[0].Shape:=stRoundSquare;
sp[0].Visible:=true;
sp[0].Show;
sp[0].:=self ;
Sp[0].OnMouseMove := AMouseMove;
end
procedure TForm1.Button1Click(Sender: TObject);
var
sp:array[0..9]of Tshape; i:integer;
begin
for i:=0 to 9 do
begin
sp[i]:=Tshape.Create(self);
sp[0].Parent:=self ;
sp[i].Left:=//位置自己调;
sp[i].Top:=//位置自己调;
sp[i].Width:=30;
sp[i].Height:=10;
sp[i].Shape:=stRoundSquare;
end;
end;//这个是把10个shape都设成同一个事件procedure TForm1.AMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Caption := IntToStr(X) + ';' + IntToStr(Y);
end;procedure TForm1.Button1Click(Sender: TObject);
var
sp:array[0..10]of Tshape;
begin
sp[0]:=Tshape.Create(self);
sp[0].Parent:=self ;
sp[0].Left:=0;
sp[0].Top:=0;
sp[0].Width:=30;
sp[0].Height:=10;
sp[0].Shape:=stRoundSquare;
sp[0].Visible:=true;
sp[0].Show;
sp[0].:=self ;
Sp[0].OnMouseMove := AMouseMove;
end
sp:array[0..10]of Tshape;
i:integer;
begin
for i:= low(sp) to high(sp) do
begin
sp[i]:=Tshape.Create(self);
sp[i].Left:=0;
sp[i].Top:=0;
sp[i].Width:=??;
sp[i].Height:=??;
sp[i].Shape:=stRoundSquare;
sp[i].Visible:=true;
sp[i].Show;
end;
end;