
Change the background color of a dialog box and change text color of Edit Box, Static Text, Rich Edit
try
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
static CBrush rBr(RGB(255,255,255));
// TODO: Change any attributes of the DC here
UINT ID = pWnd->GetDlgCtrlID();
if (ID == IDC_THE_ID_YOU_WANT)
pDC->SetBkColor(RGB(255,255,255));
return(rBr);
Quote:
}
Quote:
> The WM_CTLCOLOR would change all the edit control 's color, if i want to
> change one of the edit box.
> How i can do it?
> > Egan:
> > To change color of CEdit and CStatic you have to override WM_CTLCOLOR.
> Same
> > goes for a dialog.
> > A push button background can only be changed by making it owner draw.
Take
> a
> > look at codeguru.developer.com for examples.
> > Following MSDN articles are also helpful:
> > HOWTO: Change the Color of an MFC Child Control Class
> > Article ID: Q132080
> > HOWTO: Change the Color of an Edit Control
> > Article ID: Q74043
> > HOWTO: Change Window Background Color with Foundation Classes
> > Article ID: Q103786
> > HOWTO: Change the Background Color of an MFC Edit Control
> > Article ID: Q117778
> > SAMPLE: Owner-Draw: OdButton.exe - 3-D Push Button
> > Article ID: Q64328
> > HOWTO: Change Dialog Box Background Color in MFC 2.0 or Later
> > Article ID: Q98201
> > --
> > Ajay Kalra
> > Microsoft Visual C++ MVP
> > >Hi
> > >Does any one know how to change the background color of a dialog boxes
> > >and the buttons?
> > >How do you how to change the text color and font of an Edit Box, Static
> > >Text, and Rich Edit?
> > >Please reply soon.
> > >Thanks