为什么将ShowCaption设置为True时,TToolBar会自动计算按钮宽度? [英] Why does a TToolBar calculate button widths automatically when ShowCaption is set True?
问题描述
我需要在主窗体的右侧有两个 TToolBar
,所以我放置了三个 TPanel
进行对齐,然后将 TToolBar
放入其中。我一直在尝试告诉工具按钮
在过去一天中具有相同的宽度,但无济于事。这是我所拥有的屏幕截图:
I need to have two TToolBar
s on the right side of my main form, so I put three TPanel
s for alignment, and then put the TToolBar
s inside them. I've been trying to tell the toolbutton
s 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.
有关更多详细信息: http://zarko-gajic.iz.hr/ttoolbars-ttoolbutton-autosize-width-issues-empty-caption/
这篇关于为什么将ShowCaption设置为True时,TToolBar会自动计算按钮宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!