Click to See Complete Forum and Search --> : Changing background color of CComboBoxEx


toblo
May 20th, 1999, 06:26 AM
..having a bit of a problem with this one..

-I've overridden the OnCtlColor method of CComboBoxEx, and changed the color of the background:

...
COLORREF ActiveBkColor =(COLORREF)0xdae4e9;
static CBrush ActiveBrush(ActiveBkColor);
HBRUSH Brush;
Brush = ActiveBrush;
pDC->SetBkColor(ActiveBkColor);
return Brush;

-Looks totally OK as long as I don't look at the popped-up list, where the background of the text (only) is still white!
-Where there is no TEXT, the background color is ok..

Does anybody have an idea as to what I can do?

Regards
/Torbjörn Josefsson

May 23rd, 1999, 04:06 PM
From MSDN documentation on CWnd::OnCtlColor:

OnCtlColor will not be called for the list box of a drop-down combo box because the drop-down list box is actually a child of the combo box and not a child of the window. To change the color of the drop-down list box, create a CComboBox with an override of OnCtlColor that checks for CTLCOLOR_LISTBOX in the nCtlColor parameter. In this handler, the SetBkColor member function must be used to set the background color for the text.

kachberuni
September 14th, 2002, 10:08 AM
It does not work for me. Does anybody have a solution?

danny_boy
December 13th, 2002, 05:13 AM
Just before you set your Color in OnCtlColor, place the line:
pDC->SetBkMode(TRANSPARENT)

Hope this helps

Owen:)

Bummsfallera
September 9th, 2004, 09:03 AM
Hi,

would u be so kind and post your complete entry in the OnCtlColor?
I´ve the same problem and wonder how it works.

THX!!!!