我是创建了一个tspeedbutton数组;
var
spb:array[5] of tspeedbutton;
begin
for i:=1 to 5 do
begin
    spb:= tspeed.Create(self);
    spb.parent:= self;
    spb.Left:= xx;
    spb.Top:= xx;
end;然后要创建它们的onclick事件
procedure spb[i]click(send:tobject);
begin
.....
end;就是这一部分实现不了。
我想做到按一下新做的控件,就触发它的onclick时间。实现showmessage;
或有什么方法,实现这些新按钮的onclick事件。请赐教!

解决方案 »

  1.   

    var
    spb:array[5] of tspeedbutton;
    begin
    for i:=1 to 5 do
    begin
        spb[i]:= tspeed.Create(self);
        spb[i].name = 'spb'+IntToStr(i);
        spb[i].parent:= self;
        spb[i].Left:= xx;
        spb[i].Top:= xx;
        spb[i].onclick = spbClick;
    end;procedure spbClick(send:tobject);
    begin
      What you want to do for spb array
    end;
      

  2.   

    共用一个吧;
    procedure spbClick(sender:tobject);
    begin
      with TSpeedButton(FindComponect('spb'+InteToStr(m))) do
      begin
        ......
      end;
    end;note:m=1到5。
      

  3.   

    一般的speedbuttom控件都都有click方法,
    也就是onclick事件。如:
    procedure TForm1.SpeedButton1Click(Sender: TObject);
    begin
    showmessage('你好');end;但我自己建的控件
        spb:= tspeed.Create(self);
        spb.parent:= self;
        spb.Left:= xx;
        spb.Top:= xx;
    怎么样在.pas单元文件中实现这个procedure???按下自己建的新控件,所触发的过程就实现得了。
    我试用过写
    procedure spbClick(sender:tobject);
    begin
    showmessage('你好');
    end;
    生成的窗体,按下spb的时候,什么也没发现,
      

  4.   

    spb[i].onclick = spbClick;
    !!!!!!!!!!!