Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to simulate Windows Theme behaviour when TComboBox uses csOwnerDrawFixed or csOwnerDrawVariable?

Tags:

winapi

delphi

A very easy way to show different string values than the Items is to set the Style property from csDropDown 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 or CBS_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).

like image 471
Jeroen Wiert Pluimers Avatar asked Dec 12 '25 12:12

Jeroen Wiert Pluimers


1 Answers

Some links if people actually want to try this (you probably shouldn't as it is way too much work).

  • Problem with drawing custom Windows controls
  • Draw a themed combo box
  • Parts and States of Standard Controls and Windows
  • Biggest Vista UI change: dropdown lists now look like buttons
  • How best to create a TPanel with a close 'cross' button in the top right?
  • How i can use different text of item text in ComboBox in Delphi
  • TComboBox TOwnerDrawState OnDrawItem odComboBoxEdit
  • How a Combobox with the csOwnerDrawFixed Style can behave like the csDropDown style?
like image 190
Jeroen Wiert Pluimers Avatar answered Dec 15 '25 05:12

Jeroen Wiert Pluimers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!