Showing disabled combo text in black


Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js

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 );

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.


  • Error in excuting your code

    Posted by Legacy on 11/26/2001 12:00am

    Originally 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..

  • Custom Draw

    Posted by Legacy on 05/18/2001 12:00am

    Originally 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).

  • Solution for text coloring in CBS_DROPDOWNLIST, without subclassing

    Posted by Legacy on 11/18/1999 12:00am

    Originally posted by: Eliot Shepard

    If you trap WM_CTLCOLOR in your parent dialog, you get a callback every time the dialog is about to paint a child control. The callback params include a temp pWnd of the child and the child's pDC. Put this code in the dialog's OnCtlColor(...)

    if (pWnd->GetSafeHwnd() ==
    ((CWnd*) comboToColor)->GetSafeHwnd()) {

    This works for me under VC60 SP2. Not the most elegant thing in the world, maybe, but it works.

    This Technical Note (included in the MSDN Library), talks about the method, though it empasizes subclassing CComboBox:

    TN062: Message Reflection for Windows Controls

    Eliot Shepard

  • Need to solve this problem in ActiveX (VB6)

    Posted by Legacy on 10/26/1999 12:00am

    Originally posted by: Jens Wippermann

    I need to solve this problem in an ActiveX Combo, created in VB6. Does anyone have an idea??

  • Read Only Combos

    Posted by Legacy on 04/09/1999 12:00am

    Originally posted by: George Hunt

    Has anyone yet figured out a way to solve this problem for a CBS_DROPDOWNLIST?

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date