Obtain background color of wxComboBox set by the operating system

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Obtain background color of wxComboBox set by the operating system

Post by giulio_seb »

Hello,
I am on OSX 12.2, wxWidgets 3.1.5, and I am running a C++ code with wxWidgets.

I would like to obtain the default background color that the operating system sets to fill the rectangle of a wxComboBox. Do you know how to get it?

I tried with wxSystemSettings::GetColour(wxSystemColour index) by setting, for example index = wxSYS_COLOUR_LISTBOX, but I don't get the right color.

Thank you ! :D
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Obtain background color of wxComboBox set by the operating system

Post by doublemax »

There is no guarantee that there is a wxSystemColour index for every possible color used by the OS.

And as soon as an OS uses a gradient or any other graphical effects, a single color won't work anyway.

Even if i repeat myself: As soon as you're messing with the colors of native controls, you're on the path of evil :)
(And very likely to create a bad GUI)
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Obtain background color of wxComboBox set by the operating system

Post by ONEEYEMAN »

Hi,
Try to compile the latest release.
I think there is some work done about the "dark mode"...

Thank you.
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: Obtain background color of wxComboBox set by the operating system

Post by giulio_seb »

doublemax wrote: Mon Sep 26, 2022 8:29 pm There is no guarantee that there is a wxSystemColour index for every possible color used by the OS.

And as soon as an OS uses a gradient or any other graphical effects, a single color won't work anyway.

Even if i repeat myself: As soon as you're messing with the colors of native controls, you're on the path of evil :)
(And very likely to create a bad GUI)
Hello,
I found a solution to extract the background set by the OS. I create a dummy wxListControl, with size zero, and run GetBackgroundColour() on it. This works fine, although is not elegant ...
Post Reply