为什么将ShowCaption设置为True时,TToolBar会自动计算按钮宽度? [英] Why does a TToolBar calculate button widths automatically when ShowCaption is set True?

查看:261
本文介绍了为什么将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?

推荐答案

看看这种方法:


  1. 将所有按钮的Autosize设置为False。

  2. 在Form的OnCreate事件中调用以下内容: SendMessage( ToolBar3.Handle,TB_SETBUTTONWIDTH,0,MAKELPARAM(0,< DEFAULT_WIDTH_THAT_YOU_WANT_TO_SET&);));

  3. 请确保您未更改任何按钮的Visible属性

  4. 此外,请确保您在TB_SETBUTTONWIDTH消息的使用列表中具有 CommCtrl。

  1. Set Autosize to False for all buttons.
  2. Call the following inside Form’s OnCreate event: SendMessage(ToolBar3.Handle,TB_SETBUTTONWIDTH, 0, MAKELPARAM(0, <DEFAULT_WIDTH_THAT_YOU_WANT_TO_SET>));
  3. 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.
  4. Also, ensure you have "CommCtrl" in the uses list for TB_SETBUTTONWIDTH message.

有关更多详细信息: http://zarko-gajic.iz.hr/ttoolbars-ttoolbutton-autosize-width-issues-empty-caption/

这篇关于为什么将ShowCaption设置为True时,TToolBar会自动计算按钮宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆