[Updated 17/5/11: fixed a bug that meant pages with their Enabled property set to False weren’t being painted properly.]
The problem: say you want to customise the font colour of a tab on a tab or page control. Back in the day, this was simple — set OwnerDraw to True and provide a handler for OnDrawTab that just sets the font and draws the text. With Windows themes, however, things are not so simple, since setting OwnerDraw to True disables theming for the control. Not a VCL limitation as such, this merely reflects the behaviour of the underlying API control, and if you think about it, it makes good sense from a backwards compatibility point of view. Nonetheless, this is still an issue if you know what you want, which is simply to customise a tab’s caption. Enter, then, TTabControlEx and TPageControlEx, which use the theming API to provide the proper ‘look’ even when OwnerDraw is set to True.
Limitations: TabPosition must be tpTop (the default) and Style tsTabs (ditto) for the code to take effect. However, my code does support the Multiline property being set to True.
Minimum Delphi version: Delphi 7.
Delphi 2009+ compatibility: should be fine, since the code does not do any character crunching.
Licence: MPL 1.1.
Download: from Embarcadero CodeCentral here.