字体,背景色都可以单独设置。
HBRUSH CUDPDlg::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_STATIC_TITLE) { //设置绘图dc的背景模式为透明模式. pDC->SetBkMode(TRANSPARENT);//设置透明窗口. pDC->SetTextColor(RGB(255,255, 0));//设置文本颜色 //pWnd->SetFont(cFont);//设置字体 HBRUSH B = CreateSolidBrush(RGB(125,125,255)); return (HBRUSH) B;//作为约定,返回背景色对应的刷子句柄 //return (HBRUSH)::GetStockObject(RGB(125,125,255)); // 设置背景色 GetDlgItem(IDC_STATIC_TITLE)->GetParent()->RedrawWindow();//不重叠 } if (pWnd->GetDlgCtrlID()==IDC_RECV_LEN1) { //设置绘图dc的背景模式为透明模式. pDC->SetTextColor(RGB(255,0, 0));//设置文本颜色 //pWnd->SetFont(cFont);//设置字体 HBRUSH B = CreateSolidBrush(RGB(255,255,255)); return (HBRUSH) B;//作为约定,返回背景色对应的刷子句柄 GetDlgItem(IDC_RECV_LEN1)->GetParent()->RedrawWindow();//不重叠 } // TODO: Return a different brush if the default is not desired return hbr; }