用什么代码可以实现生成一个ToolButton?

joanagle 2005-01-05 03:08:48
即相当于在ToolBar上点击右键选择'New Button'?
急,谢谢!
在线!
...全文
68 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
juny0302 2005-01-05
  • 打赏
  • 举报
回复
To use this example, create a new application and add the example code to the unit.

procedure AddButtons(ToolBar: TToolBar;

Const ButtonCaptions: array of String);
var
I: Integer;
begin
for I := 0 to High(ButtonCaptions) do
begin
with TToolButton.Create(ToolBar) do
begin
Parent := ToolBar;
Caption := ButtonCaptions[I];
if (ButtonCaptions[I] = '|') then
Style := tbsSeparator
else
Style := tbsButton;

end;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
ToolBar: TToolBar;
begin
ToolBar := TToolBar.Create(Self);
ToolBar.Parent := Self;
AddButtons(ToolBar, ['New', 'Save', '|', 'Cut', 'Copy', 'Paste']);
ToolBar.ShowCaptions := True;
ToolBar.Height := 40;
end;
何鲁青 2005-01-05
  • 打赏
  • 举报
回复
没找到

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧