HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if (pWnd->GetDlgCtrlID() == IDC_STATICText) { pDC->SetBkColor(RGB(0,255,0));//文字背景色为绿色 需要返回对应颜色画刷,才能填充没有文字的背景 pDC->SetTextColor(RGB(255, 0, 0));//文字为红色 pDC->SelectObject(&m_font);//文字为15号字体,华文行楷 return m_brush; // 需要返回对应颜色画刷,才能画满完全的背景 } // TODO: Return a different brush if the default is not desired return hbr; }