I noticed that the height of a TToolButton increases when you set the button’s Style to tbsDropdown. I can understand the width increasing, so the button has space to draw the down arrow, but I’m not sure a height increase is necessary.
Steps to reproduce the issue (Delphi 2010, Windows 7 x64):
- Add TToolbar to a form, ShowCaptions=True
- Right click to add a button to the Toolbar
- Set button Style=tbsDropDown and notice the button grows in height
The same height increase happens when there are images assigned to the
toolbar, in which case there is already plenty more vertical space available
in the button to draw the drop down.
Here’s a visual example:
alt text http://img440.imageshack.us/img440/1462/ttoolbar02.png
alt text http://img291.imageshack.us/img291/966/ttoolbar01.png
Is there a workaround for this without hacking the VCL, or is this hardcoded into the Windows control?
It’s part of the underlying Windows control. A quick look into
ComCtrlsshows that changing theTToolButton.Stylecalls it’sSetStylemethod. If, inSetStyle,ShowCaptionsis True then theTToolBar.ButtonWidthandButtonHeightare both set to 0, andTToolButton.RecreateButtonsis called.RecreateButtons, in turn, callsTToolBar.ResizeButtons, which simply sends (posts) a message to theToolBarusingTB_AUTOSIZEis intended to be used, according to MSDN,Since
SetStylesets both theButtonWidthandButtonHeightto 0, this message would seem to be correctly sent.