A very easy way to show different string values than the Items is to set the Style property fromcsDropDown
to csOwnerDrawFixed
as Andreas Rejbrand has answered a few years ago.
The thing is: as soon as you do that, you loose Windows Theming support.
The same limitation applies to using csOwnerDrawVariable
These two Style
values get translated into adding the CBS_OWNERDRAWFIXED
orCBS_OWNERDRAWVARIABLE
(in addition to CBS_DROPDOWNLIST
) styles of the Windows COMBOBOX control.
In turn, CBS_OWNERDRAWFIXED
or CBS_OWNERDRAWVARIABLE
cause you to instantly loose the Windows theming support.
When you do full custom painting like a colour picker, that is all fine. But when you only want to replace the drawn text, it is not.
The Windows COMBOBOX control does not seem to have a way around this, so I’m wondering: how can you simulate the Windows theming from Delphi?
I assume it has to do with DrawThemedBackground, but it has been a while since I’ve done serious Delphi Control work, so any pointers on how to get started there are fine too (even if they invalidate my assumption).
TComboBoxStyleHook
. – David Heffernan Sep 9 at 13:13Business Layer
gives me aTStrings
with theObjects
filled (it is pre-Delphi-2009, so no generics yet). That’s why I can get out theText
sou easy (: First I need to finish about a week of .NET work though. – Jeroen Wiert Pluimers Sep 10 at 16:03TExtComboBox
and its own VCL styles feature. – Warren P Sep 10 at 20:45Object
instance references are already in theTStrings
, I wrote a small function to return a new temporaryTStrings
that has the string values with the captions I needed and keep theObject
references. Since it has the same item ordering, and sameObject
references I don’t need any mapping at all. Just need to make sure I free the newTStrings
at the right moment. – Jeroen Wiert Pluimers Sep 10 at 21:24