1.新建基于对话框的工程,添加Static控件,ID设为:IDC_STATIC1;
2.添加变量:
CBrush m_brush;
CFont m_font;
3.OnInitDialog()中初始化设置:
m_font.CreatePointFont(150,"华文行楷");
m_brush.CreateSolidBrush(RGB(0,255,0));
4.添加WM_CTRLCOLOR消息,响应函数中添加:
// TODO: Change any attributes of the DC here
switch(pWnd->GetDlgCtrlID())
{
case IDC_STATIC1:
pDC->SetBkMode(TRANSPARENT);
pDC->SelectObject(&m_font);
pDC->SetTextColor(RGB(255,0,0));
break;
}