添加消息响应WM_CTLCOLOR,代码如下:
HBRUSH CTest1Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
CFont m_font; //声明变量
m_font.CreatePointFont(600,"华文行楷"); //设置字体大小和类型
if(pWnd->GetDlgCtrlID()==IDC_STATIC01)
{
pDC->SelectObject(&m_font); //设置字体
pDC->SetTextColor(RGB(0,0,255)); //设置字体颜色
pDC->SetBkMode(TRANSPARENT); //属性设置为透明
return (HBRUSH)::GetStockObject(NULL_BRUSH); //不返回画刷
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
CFont m_font; //声明变量
m_font.CreatePointFont(600,"华文行楷"); //设置字体大小和类型
if(pWnd->GetDlgCtrlID()==IDC_STATIC01)
{
pDC->SelectObject(&m_font); //设置字体
pDC->SetTextColor(RGB(0,0,255)); //设置字体颜色
pDC->SetBkMode(TRANSPARENT); //属性设置为透明
return (HBRUSH)::GetStockObject(NULL_BRUSH); //不返回画刷
}
// TODO: Return a different brush if the default is not desired
return hbr;
}