Showing disabled combo text in black | CodeGuru

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. […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 6, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.