Click to See Complete Forum and Search --> : changing the color of text in MFC


qwerty
May 5th, 1999, 12:07 AM
I am trying to change the color of the text in a text box in an MFC application, can anyone help me. Or if anyone knows a better type of control to use which would work in MFC that would be great too. Thanks

kals
May 5th, 1999, 01:16 AM
You have to overide OnCtlColor()
as given below with the WM_CTLCOLOR inside

BEGIN_MESSAGE_MAP

HBRUSH CMydialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

if(nCtlColor == CTLCOLOR_STATIC)
hbr = CreateSolidBrush(RGB(O,O,O);
pDC->SetBkColor(RGB(O,O,O));
pDC->SetTextColor(RGB(255,255,255
));


// TODO: Return a different brush if the default is not desired
return hbr;
}


the above code will have a black background

and white text color for all the static text

you have created.

if you have still doubt mail at the same place

kals

Thanks for reading the mail.

Expecting a postivie Reply

kals