CComboBox Read-Only

Ok...I know that you can get the child window of the combo box and set it to read only. But how do I make it so the box is still white and not gray. Also...I do not want to se the blinking caret in the window.
SGyvesAsked:
Who is Participating?
 
Roshan DavisConnect With a Mentor Commented:
Map WM_CTLCOLOR, dialog will sent this message for this EDIT as *STATIC* (only when disabling an EDIT)

Try this code

HBRUSH CTestPrograms_DLGDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
      HBRUSH hbr;
      
      if ( nCtlColor == CTLCOLOR_STATIC )
      {
            hbr = (HBRUSH)GetStockObject(WHITE_BRUSH);
      }
      else
      {
            hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
      }
            
      // TODO: Return a different brush if the default is not desired
      return hbr;
}

You can check the window pointer or ID for coloring  specific read only edit.

I'm checking the Blinking caret issue

Good Luck
0
 
PriyeshCommented:
To remove the blinking caret, once you have the edit window,

pEdit->HideCaret() ;
0
 
Roshan DavisCommented:
addition to Priyesh's comment:
map EN_SETFOCUS and there also call "HideCaret()"

Rosh :)
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
AlexFMCommented:
Maybe all you need is dropdown list style (just a guess...)
0
 
SGyvesAuthor Commented:
OMG!!! Alex....you are absolutely right.....LOL
0
 
SGyvesAuthor Commented:
Although all I needed was what AlexFM suggested...I will give the points to rosh for the most direct answer to the question. Thanks.
0
 
AlexFMCommented:
Well... I should learn to give direct answers.
0
 
SGyvesAuthor Commented:
No...no...that was not my point at all....I hope you are not offended...I really appreciate your answer....I am sorry for not giving the points to you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.