Extended Delphi Buttons

The Delphi TButton class does not allow multiline captions, or captions that contain mixed fonts, styles, sizes or colors. This is not such a big problem as it might seem at first sight - since TButton is a TWinControl descendant one should be able to simply insert labels inside the button and arrange them to obtain the desired effect.

Easy right? Well yes, except for the fact that the TButton constructor leaves out csAcceptsControls value from the ControlStyle set property. This being the case it is not possible to drag and drop other controls onto a TButton in the Delphi form designer. However, there is nothing to stop you from directly editing the .dfm file to have controls owned by an instance of TButton. Here are the steps:

You must ensure that the labels do not obscure any of the button borders or else the button will appear unresponsive to the user. A 5 pixel gap all around is all that is required to ensure that WindowsXP style button effects are visible at all screen resolutions. This technique works perfectly. However, as the number of controls hosted inside the button increases you may notice that the button redraw slows down.

Download
Jump To...

Colophon