为什么将ShowCaption设置为True时,TToolBar会自动计算按钮宽度?

编程入门 行业动态 更新时间:2024-10-28 17:21:35
本文介绍了为什么将ShowCaption设置为True时,TToolBar会自动计算按钮宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要在主窗体的右侧有两个 TToolBar ,所以我放置了三个 TPanel 进行对齐,然后将 TToolBar 放入其中。我一直在尝试告诉工具按钮在过去一天中具有相同的宽度,但无济于事。这是我所拥有的屏幕截图:

I need to have two TToolBars on the right side of my main form, so I put three TPanels for alignment, and then put the TToolBars inside them. I've been trying to tell the toolbuttons to have the same width for the past day, to no avail. Here's a screen shot of what I've got:

我发现,如果 ShowCaption 设置为 True ,则工具栏会计算按钮宽度自动。我的问题是为什么,以及如何禁用它?

I found out that if ShowCaption is set to True, the toolbars calculate the button width automatically. My question is why, and how to disable this?

推荐答案

看看这种方法:

  • 将所有按钮的Autosize设置为False。
  • 在Form的OnCreate事件中调用以下内容: SendMessage( ToolBar3.Handle,TB_SETBUTTONWIDTH,0,MAKELPARAM(0,< DEFAULT_WIDTH_THAT_YOU_WANT_TO_SET&);));
  • 请确保您未更改任何按钮的Visible属性
  • 此外,请确保您在TB_SETBUTTONWIDTH消息的使用列表中具有 CommCtrl。
  • Set Autosize to False for all buttons.
  • Call the following inside Form’s OnCreate event: SendMessage(ToolBar3.Handle,TB_SETBUTTONWIDTH, 0, MAKELPARAM(0, <DEFAULT_WIDTH_THAT_YOU_WANT_TO_SET>));
  • Make sure you do not alter the Visible property of any buttons before the above call – as it will fail for those buttons that are not visible.
  • Also, ensure you have "CommCtrl" in the uses list for TB_SETBUTTONWIDTH message.
  • 有关更多详细信息: zarko-gajic.iz.hr/ttoolbars-ttoolbutton-autosize-width-issues-empty-caption/

    更多推荐

    为什么将ShowCaption设置为True时,TToolBar会自动计算按钮宽度?

    本文发布于:2023-06-12 23:56:44,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/670241.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:设置为   宽度   按钮   ShowCaption   TToolBar

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!