怎么使动态添加的ToolButton在ToolBar已有按键的后面??

COKING 2004-07-03 03:10:15
哎!越来越搞不懂了!!!
...全文
83 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sczyq 2004-07-03
  • 打赏
  • 举报
回复
int ButtonLeft = 0;
for (int i=0; i<SysToolBar->ControlCount;i++)
if (ButtonLeft <= SysToolBar->Controls[i]->Left)
ButtonLeft = SysToolBar->Controls[i]->Left
+ SysToolBar->Controls[i]->Width;

TSpeedButton *NewButton = new TSpeedButton(this);
NewButton ->Parent = SysToolBar;
NewButton ->Top = 2;
NewButton ->Left = ButtonLeft + 1; // 至少加1
jishiping 2004-07-03
  • 打赏
  • 举报
回复
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TToolButton* Btn = new TToolButton(this);
if (ToolBar1->ButtonCount > 0) {
TToolButton* Btn0 = ToolBar1->Buttons[
ToolBar1->ButtonCount-1];
Btn->Left = Btn0->Left + Btn0->Width;
Btn->Top = Btn0->Top;
}
Btn->Parent = ToolBar1;
//这儿加上 Btn 的其它设定
}

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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