16,748
社区成员
发帖
与我相关
我的任务
分享
procedure TF_Main.btn2Click(Sender: TObject);
var
i: integer;
lblview: TLabel;
lstBtn: TList;
btn: TButton;
begin
mmotest.Lines.Clear;
lstBtn := TList.Create;
try
for i := ControlCount-1 downto 0 do
begin
if (controls[i] is TButton) and
((controls[i] as TButton).tag = 0) then
begin
lstBtn.Add( Controls[i] );
end;
end;
for i := 0 to lstBtn.Count-1 do
begin
btn := TButton(lstBtn[i]);
lblView := Tlabel.Create(Self);
lblView.parent := self;
lblView.tag := 1;
lblview.Height := btn.height;
lblview.width := btn.width;
lblview.top := btn.top;
lblview.left := btn.left;
lblview.font := btn.font;
lblview.caption := btn.caption;
lblview.visible := true;
btn.Visible := false;
end;
finally
lstBtn.Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
lblview: TLabel;
begin
for i := self.ControlCount-1 downto 0 do
begin
if (self.controls[i] is TButton) then
if ((self.controls[i] as TButton).tag = 0) then
begin
lblView := Tlabel.Create(Self);
lblView.parent := self;
lblView.tag := 1;
lblview.Height := (Self.controls[i] as TButton).height;
lblview.width := (self.controls[i] as TButton).width;
lblview.top := (self.controls[i] as TButton).top;
lblview.left := (self.controls[i] as TButton).left;
lblview.font := (self.controls[i] as TButton).font;
lblview.caption := (self.controls[i] as TButton).caption;
lblview.visible := true;
lblview.show;
(Self.Controls[i] as TButton).Visible := false;
end;
end;
end;