//代码来源于一本书<<Visual C++程序设计自学手册>>
//10.3的实例,控制打印方向
//我想改变窗口的背景颜色,因此重新设置了RGB的值为RGB(255,0,255),所以应该显示红色
HBRUSH CPrintBearingDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
CBrush m_brush (RGB(255,0,0));
CRect m_rect;
GetClientRect(m_rect);
pDC->FillRect(m_rect,&m_brush);
// TODO: Return a different brush if the default is not desired
return m_brush;
}
然而显示结果如下:
并未正确填充
所以就想到了之前遇到的问题,Visual C++ FillRect 总是白色
http://blog.csdn.net/popppig/article/details/6695453
增加了 pDC=GetDC()
之后运行结果如下:
还是没有正确显示,继续探索中,尚未解决~