Hi, ALL,
Is there a way to change the background color of the combo box? Asking because there is no CTLCOLOR event for this control...
Thank you.
Printable View
Hi, ALL,
Is there a way to change the background color of the combo box? Asking because there is no CTLCOLOR event for this control...
Thank you.
You can manually add your own CTLCOLOR functionality, CWnd supports it.
you can add any MFC functionality manually, or you can use the wizzards . . . doesn't really much matter. . . There are many other settings you can affect from here as well . . .Code://in the .h file
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
//in the .cpp file
ON_WM_CTLCOLOR()
HBRUSH CYourClass::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
int
nCtrlID = pWnd->GetDlgCtrlID();
HBRUSH
hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch(nCtlColor)
{
case CTLCOLOR_EDIT:
pDC->SetTextColor(RGB(255, 0, 0));
hbr = (HBRUSH)GetStockObject(WHITE_BRUSH);
break;
case CTLCOLOR_STATIC:
pDC->SetTextColor(RGB(0, 0, 128));
pDC->SetBkColor(GetSysColor(COLOR_BTNFACE));
hbr = GetSysColorBrush(COLOR_BTNFACE);
break;
case CTLCOLOR_BTN:
pDC->SetTextColor(RGB(128, 0, 0));
pDC->SetBkColor(GetSysColor(COLOR_BTNFACE));
hbr = GetSysColorBrush(COLOR_BTNFACE);
break;
case CTLCOLOR_LISTBOX:
pDC->SetTextColor(RGB(128, 0, 0));
pDC->SetBkColor(GetSysColor(COLOR_BTNFACE));
hbr = GetSysColorBrush(COLOR_BTNFACE);
break;
default:
hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
break;
}
return hbr;
}
Perfect Health and Clarity of Mind,
--Victor
That doesn't mean "adding your own CTLCOLOR functionality" but mapping a handler function for WM_CTLCOLOR message.
Of course, you can manually map any message but the wizard helps you doing it faster and prevents making mistakes.
What "other settings"?
Thank you for the reply, guys.
Is there a straight Win32 way - no MFC?