TToolButton height grows with style = tbsDropdown

I noticed that the height of the TToolButton increases when you set the Style button to tbsDropdown. I can understand that the width is increasing, so the button has a place to draw a down arrow, but I'm not sure if the height increase is necessary.

Steps to reproduce the problem (Delphi 2010, Windows 7 x64):

  • Add TToolbar to the form, ShowCaptions = True
  • Right-click to add a button to the toolbar.
  • Set the button Style = tbsDropDown and notice that the button is growing in height

The same increase in height occurs when there are images assigned to the toolbar, in which case there is already more vertical free space in the button for falling down.

Here is 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 VCL, or is it hardcoded in a Windows control?

+7
delphi
source share
2 answers

This is part of the main Windows control. A quick look at ComCtrls shows that changing TToolButton.Style calls the SetStyle method. If SetStyle , ShowCaptions is True, then TToolBar.ButtonWidth and ButtonHeight are 0, and ButtonHeight is called.

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

 Perform(TB_AUTOSIZE, 0, 0); 

TB_AUTOSIZE is for use in accordance with MSDN ,

after resizing the toolbar, either by setting the size of the button or bitmap, or by adding lines for the first time.

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

+3
source share

There seems to be something wrong with theme support in basic Windows management. Turn off work themes (Project / Options / Application, uncheck "Enable runtime tags"), ignore the increased button heights during development (Delphi IDE uses themes) and run the application - you will see the normal height of the buttons on the toolbar.

+1
source share

All Articles