Showing disabled combo text in black

The same problem is encountered in Windows' Find File, the one that you run from the Start button menu. While it performs the search, the search pattern is dimmed.
IDC_COMBO is a combo control of a dialog box. The code that follows is placed in the dialog's OnInitDialog handler, here it is:
// Make the disabled combo's edit control appear as enabled & R/O
// 1. The first child window of a combo is its edit control
CEdit* pComboEdit=(CEdit*)(GetDlgItem( IDC_COMBO )->GetWindow(GW_CHILD ));
// 2. Enable combo's edit control, not the combo itself, and set R/O
pComboEdit->EnableWindow( TRUE );
pComboEdit->SetReadOnly();
However, this approach does not work when the combo box is of the DropList type, since such a combo consists of two windows only, the combo itself and the combo list control, and, therefore, I can't enable it.
And also, overriding the OnCtlControl handler in order to change colors doesn't help - there is no problem to change the text background color, but the text color still appears dimmed.

Comments
Error in excuting your code
Posted by Legacy on 11/26/2001 12:00amOriginally posted by: DASSLEYO
First of all I thank you for ur code.
I tried urs in my program and i ahve execution error.
Actually i have a combo box in my dialog and i am able to disable it by m_NbreMachineCtrlENABLEWINDOW(FALSE); and also by properties but i could not the change colour to grey.
COuld u pleas help me if u have sloution SOS.
Thank u in advance..
ReplyCustom Draw
Posted by Legacy on 05/18/2001 12:00amOriginally posted by: Andre Romanov
The problem has a very simple solution by Custom Draw. But it works for the case without edit control only (see Q82078).
ReplySolution for text coloring in CBS_DROPDOWNLIST, without subclassing
Posted by Legacy on 11/18/1999 12:00amOriginally posted by: Eliot Shepard
ReplyNeed to solve this problem in ActiveX (VB6)
Posted by Legacy on 10/26/1999 12:00amOriginally posted by: Jens Wippermann
I need to solve this problem in an ActiveX Combo, created in VB6. Does anyone have an idea??
ReplyRead Only Combos
Posted by Legacy on 04/09/1999 12:00amOriginally posted by: George Hunt
Has anyone yet figured out a way to solve this problem for a CBS_DROPDOWNLIST?
Reply