第二种方法我试了,但是不行,颜色是蓝色 代码如下: HBRUSH CDlgPatientQuery::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here switch(nCtlColor) { case CTLCOLOR_DLG: hbr = ::CreateSolidBrush(CONST_COLOR_DLG_BG_2); break; case CTLCOLOR_STATIC: pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(CONST_COLOR_DLG_TEXT); hbr = (HBRUSH) (::GetStockObject(HOLLOW_BRUSH)); break; case CTLCOLOR_EDIT: pDC->SetTextColor(CONST_COLOR_DLG_TEXT); pDC->SetBkColor(CONST_COLOR_DLG_BG_3); hbr = ::CreateSolidBrush(CONST_COLOR_DLG_BG_3); break; default: break; } // TODO: Return a different brush if the default is not desired return hbr; }
加入
if(pWnd->GetDlgCtrlID() == IDC_STATIC_GROUP)
pDC->SetTextColor(RGB(255, 0, 0));
代码如下:
HBRUSH CDlgPatientQuery::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here
switch(nCtlColor)
{
case CTLCOLOR_DLG:
hbr = ::CreateSolidBrush(CONST_COLOR_DLG_BG_2);
break;
case CTLCOLOR_STATIC:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(CONST_COLOR_DLG_TEXT);
hbr = (HBRUSH) (::GetStockObject(HOLLOW_BRUSH));
break;
case CTLCOLOR_EDIT:
pDC->SetTextColor(CONST_COLOR_DLG_TEXT);
pDC->SetBkColor(CONST_COLOR_DLG_BG_3);
hbr = ::CreateSolidBrush(CONST_COLOR_DLG_BG_3);
break;
default:
break;
} // TODO: Return a different brush if the default is not desired
return hbr;
}