小弟新手一个,求各路大侠帮忙。在WM_CTLCOLOR消息里设置字体,响应函数如下:HBRUSH CSerialPortComDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here
// 设置显示字体

 CFont * cf=new CFont;//;static
cf->CreateFont(16,0,0,0,FW_SEMIBOLD,FALSE,FALSE,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH&FF_SWISS,"Arial");

switch (pWnd->GetDlgCtrlID())
{
//针对ID为IDC_CTL1, IDC_CTL2和IDC_CTL3的控件进行同样的设置
case IDC_CTL1:
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,255,255)); pWnd->SetFont(cf);//取消是正常 HBRUSH B = CreateSolidBrush(RGB(0,0,0));
return (HBRUSH) B;
}
default:
return hbr;//CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
// TODO: Return a different brush if the default is not desired return hbr;
}
当取消 pWnd->SetFont(cf);时界面能够正常显示;
当加上这句代码就出问题了:编辑框里的数据(数字)不停的闪烁,单击一下编辑框,背景就变成白色的了,数据还是在闪烁。