Originally posted by: Christopher W. Backen
default:
HBRUSH blah::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch (nCtlColor) {
case CTLCOLOR_STATIC:
pDC->SetTextColor(RGB(255, 255, 255));
pDC->SetBkColor(RGB(0, 0, 0));
case CTLCOLOR_EDIT:
pDC->SetTextColor(RGB(255,255,255));
pDC->SetBkColor(RGB(0,0,0));
case CTLCOLOR_LISTBOX:
pDC->SetTextColor(RGB(255,255,255));
pDC->SetBkColor(RGB(0,0,0));
case CTLCOLOR_SCROLLBAR:
pDC->SetTextColor(RGB(255,255,255));
pDC->SetBkColor(RGB(0,0,0));
case CTLCOLOR_BTN:
pDC->SetTextColor(RGB(255,255,255));
pDC->SetBkColor(RGB(0,0,0));
case CTLCOLOR_DLG:
return m_pBkBrush;
return m_pBkBrush;
}
}
Originally posted by: Septimiu
Hello,
The code above works well to change the color of a dialog.
But how can I change the background of a CRichEditCtrl ?
I know the method SetBackgroundColor(BOOL bSysColor, COLORREF cr);
but when I am in 256 colors the desired color is change in the
nearest color (from light yellow to white e.g.)
So it would be perfect if I could change the background using
a brush like in OnCtlColor().
Any sugestion/information is appreciated.
Thank you, Septimiu
Originally posted by: Omer Eisenberg
This thing worked for me. The problem is that the brush is
painted on the entire dialog, including the controls.
In order to prevent this add the following in your
'OnCtlColor':
HBRUSH CDlgLoadDB::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_DLG) // draw dialog only
return (m_brush);
else
return (CDialog::OnCtlColor(pDC, pWnd, nCtlColor));
}
Originally posted by: Luis Garcia
HBRUSH CAboutDlg::OnCtlColor...
it should be:
HBRUSH CTestDlg::OnCtlColor...
Please, take note and sorry for the inconvenience.
Luis
There is a small typo on the method:
Reply
Originally posted by: Ben
No good---try yourself