TToolButton Height Grows with Style = tbsDropdown

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 alt text

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 ComCtrls shows that changing the TToolButton.Style calls it's SetStyle method. If, in SetStyle, ShowCaptions is True then the TToolBar.ButtonWidth and ButtonHeight are both set to 0, and TToolButton.RecreateButtons is called.

RecreateButtons, in turn, calls TToolBar.ResizeButtons, which simply sends (posts) a message to the ToolBar using

Perform(TB_AUTOSIZE, 0, 0);

TB_AUTOSIZE is intended to be used, according to MSDN,

after causing the size of a toolbar to change either by setting the button or bitmap size or by adding strings for the first time.

Since SetStyle sets both the ButtonWidth and ButtonHeight to 0, this message would seem to be correctly sent.

Looks like something is wrong with the theme support in underlying windows control. Switch off the runtime themes (Project/Options/Application, uncheck "Enable runtime themes" checkbox), ignore the increased button heights at design time (Delphi IDE uses themes) and run the application - you will see normal heights of the toolbar buttons.

Need Your Help

Images fixed position despite resolution

html css

On my website I would like to have several images across the width of my page. When I am on my laptop (resolution: 1366x768) there's 7 image next to each other. When I test it on my smartphone ther...

When might you not want to use garbage collection?

memory-management garbage-collection

Garbage collection has been around since the early days of LISP, and now - several decades on - most modern programming languages utilize it.