问题
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:
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:
Take a look at this approach:
- 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.
 
For more details: http://zarko-gajic.iz.hr/ttoolbars-ttoolbutton-autosize-width-issues-empty-caption/
回答2:
You can use object inspector to set the button width with static value, or you can use formcreate or onpaint or onresize etc to set the value dynamically........
来源:https://stackoverflow.com/questions/15219524/why-does-a-ttoolbar-calculate-button-widths-automatically-when-showcaption-is-se