Showing disabled combo text in black

I hope that the picture I am hereby attaching speaks for itself: the
IP-address in Fig.2 is easily readable, while the parameters in Fig.1
are not.

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.

More by Author

Must Read