发信人: zxg (魔), 信区: BorlandDev
标  题: Re: 如何将制造控件数组?(From database board)
发信站: 哈工大紫丁香 (2000年08月30日08:39:18 星期三), 站内信件

hehe...
我找到了方法:
首先建立一个函数:Function1
将要用这个函数响应事件的控件用以下方法定义:
比如是按扭的OnClick事件:
 for(int i=0;i<5;i++)
 {
  Button[i]=new TButton(this);
  Button[i]->Parent=this;
  Button[i]->Top=30*i+10;
  Button[i]->Caption="Button"+IntToStr(i);
  Button[i]->OnClick= Function1;
 }

在Function1函数中做如下处理
void __fastcall TForm1::Function1(TObject * Sender)
{
 TComponent *Show;
 Show=(TComponent *)Sender;
 ShowMessage(IntToStr(Show->ComponentIndex));
}

可以用ComponentIndex这个属性来区分是哪个控件发出的消息!


--
                               ★
                             ★  ★
                            ★星星★
                           ★★★★★

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.228.205]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.359毫秒