954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

CComboBox Background Color Change Needed

Hi to all...
In a MFC application,
I need to change the background color of a drop down list - combo box control.

IDC_MYCOMBO is the resource id and
m_myCombo is the name of the control.

I need to change the backcolor programmatically.
Is there a way to achieve that?

Thanks

fulyaoner
Light Poster
29 posts since May 2006
Reputation Points: 10
Solved Threads: 2
 

I will answer to myself :)

HBRUSH CMYDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
 
 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
 
 CPaintDC dc(this);
 if(nCtlColor == CTLCOLOR_EDIT && pWnd->GetDlgCtrlID() == IDC_MYCOMBO)  {
  pDC->SetTextColor(RGB(0, 0, 0));
  pDC->SetBkColor(RGB(255, 90, 90));
  hbr = m_myBrush;
 }
 
 return hbr;
}


may be it will help to others someday.

fulyaoner
Light Poster
29 posts since May 2006
Reputation Points: 10
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You