unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure test(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.test(Sender: TObject);
var
l_busin_flag:Integer;
begin
l_busin_flag:=(Sender as TButton).Tag;
ShowMessage(IntToStr(l_busin_flag)+'Hello');
end;
procedure TForm1.FormCreate(Sender: TObject);
var
btns: TButton;
i:Integer;
begin
for i:=0 to 5 do
begin
btns:=TButton.Create(Self);
btns.Width:=100;
btns.Height:=20;
btns.Caption:=IntToStr(i)+'动态按钮';
btns.OnClick:=test;
btns.Left:=i*100;
btns.Tag:=i;
btns.Parent:=Self;
end;
end;
end.
转自:https://blog.csdn.net/opensource_liu/article/details/47837375
© 版权声明
文章版权归作者所有,未经允许请勿转载。