1) You need specify ID different than IDC_STATIC for the label in question.
Here we used IDC_COLORED_LABEL in the sample code.
2a) MFC project
Add WM_CTLCOLOR handler for the dialog and modify it as follows:
HBRUSH CDialogDlg::OnCtlColor(CDC* pDC, CWnd* pWnd,
UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_COLORED_LABEL)
pDC->SetTextColor(RGB(128, 0, 0));
return hbr;
}
Note that MFC uses OnCtlColor method to handle all types of WM_CTLCOLORXXX
messages.
2b) Windows API
End the body of WM_CTLCOLORSTATIC dialog message handler with
return (BOOL) GetSysColorBrush(COLOR_3DFACE);
It is important that a valid brush handle, not TRUE or FALSE is returned.
HTH