示例一: implementation
var
T1:TToolButton;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
T1:=TToolbutton.Create(self);
T1.Parent:=toolbar1;
T1.Caption:=’show’;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
T1.Free;
end;
示例二:
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(ToolButton1.Owner.Name);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with TToolButton.Create(Self) do
begin
Parent := ToolBar1;
Caption := ’asdf’;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if ToolBar1.ButtonCount <> 0 then
ToolBar1.Buttons[0].Free;
end;
(
www.cncfan.com搜集整理 感谢‘chinaandys’,‘g961681’两位网友。)