我的动态生成的按钮是N个,从INI里调用字符生成(生成的caption为str1[i]数组)。每个生成的按钮点击都有自己的属性是打开不同的文件,打开文件的路径也是从INI文件里调用出来的(路径的数组为str2[i]),一个按钮对应一个路径。问题是怎么写这个触发函数,下面这个写法肯定是不行的,因为调用不了每个按钮不同的路径,请问大家应该怎么写?
var
temp:Tbutton;
..........................(此处省略生成按钮的杂项,返回了两个数组的值)
begin
with TButton.Create(self) do
begin
temp.parent:=pannel1;
temp.Caption :=str1[1];
temp.onclick:=myclick;
end;
end;procedure TForm1.myclick(Sender: TObject);
begin
showmessage('clicked');
end;
var
temp:Tbutton;
..........................(此处省略生成按钮的杂项,返回了两个数组的值)
begin
with TButton.Create(self) do
begin
temp.parent:=pannel1;
temp.Caption :=str1[1];
temp.onclick:=myclick;
end;
end;procedure TForm1.myclick(Sender: TObject);
begin
showmessage('clicked');
end;
解决方案 »
- delphi 写一个下载程序,就像下载游戏前的那个下载软件,怎么样得到下载速率?
- delphi7编译器左边下角的两个面板怎么打开?
- BusinessSkinForm.v6.07.FS使用问题?
- 问一个搜索后字符串选中的问题。
- 如何利用DELPHI的 Tseversocket Tclientsocket 实现一个bmp文件的传输?急需答复!谢!
- 那里有绝望生鱼片下载呀,要求mp3格式的,chinamp3上居然不能下载!
- 马上给分,那里有讲解delphi创建dll的比较好的资料
- 高手请进:急啊,两天来一直困绕我的问题。
- 怎样让webbrowser读取流文件?
- 一个双指针的C++接口,如何使用DELPHI声明和调用
- 怎么实现无闪烁动画
- 在Delphi3中,使用MediaPlayer控件问题! 急.... 各位高手谢谢啦
temp:Tbutton;
..........................(此处省略生成按钮的杂项,返回了两个数组的值)
begin
with TButton.Create(self) do
begin
temp.parent:=pannel1;
temp.Caption :=str1[1];
temp.tag:='你的路径';
temp.onclick:=myclick;
end;
end;procedure TForm1.myclick(Sender: TObject);
begin
showmessage(TButton(sender).tag);
end;
var
temp:Tbutton;
..........................(此处省略生成按钮的杂项,返回了两个数组的值)
begin
with TButton.Create(self) do
begin
temp.parent:=pannel1;
temp.Caption :=str1[1];
temp.tag:=str2[1];
temp.onclick:=myclick;
end;
end;procedure TForm1.myclick(Sender: TObject);
begin
showmessage(TButton(sender).tag);
end;
我的意思是在myclick()中能解决按钮的所含的路径问题,在myclick()不可能直接引用上面那个函数的数组str2[]吧,应该怎么解决这个问题
var
tempI :integer;............
tempi:=0;
...........var
temp:Tbutton;
..........................(此处省略生成按钮的杂项,返回了两个数组的值)
begin
with TButton.Create(self) do
begin
temp.parent:=pannel1;
temp.Caption :=str1[tempI];
temp.tag:=str2[tempI];
temp.onclick:=myclick;
end;
inc(tempI)
end;procedure TForm1.myclick(Sender: TObject);
begin
showmessage(TButton(sender).tag);
end;