在你的程序里面添加一个CBrush m_brush;变量。 然后在OnInitDialog中载入位图, m_brush.CreatePatternBrush(IDB_YOUBITMAP); 然后处理WM_CTLCOLOR消息, 并返回m_brush; 如下: HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);// TODO: Change any attributes of the DC here hbr = m_brush; // TODO: Return a different brush if the default is not desired return hbr; }
STEP2:在注册一个窗口时,创建一个 BMP 类型的刷子:
Map1=LoadBitmap(me,MAKEINTRESOURCE(IDB_BACKGROUND));
Brush1=CreatePatternBrush(system_data.Map1);
STEP3:使这个刷子成为底图的画刷:
wc.hbrBackground=Brush1;
然后在OnInitDialog中载入位图,
m_brush.CreatePatternBrush(IDB_YOUBITMAP);
然后处理WM_CTLCOLOR消息,
并返回m_brush;
如下:
HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);// TODO: Change any attributes of the DC here
hbr = m_brush;
// TODO: Return a different brush if the default is not desired
return hbr;
}