
Changing color of static text on a Dialog
After all these years as a VC++ developer I am embarrassed to admit I forgot
how to change the color of a static text control on a Dialog.
This code does not work when added to OnInitDialog():
#define RGB_RED RGB(255, 0, 0)
CStatic* pWndStaticColor = (CStatic*)GetDlgItem(IDC_COLOR_TEST_STATIC);
CDC * pDC = pWndStaticColor->GetDC();
COLORREF oldTextColor = pDC->SetTextColor(RGB_RED);
Changing the first line as follows didn't fix it.
CWnd* pWndStaticColor = GetDlgItem(IDC_COLOR_TEST_STATIC);
I also tried putting this code snippet before and after
CDialog::OnInitDialog(). This didn't help either.
What am I missing here?
Michael T.