在头文件里定义一个CBrush brush; 在该窗口初始化时: brush.CreateSolidBrush(RGB(255,0,0)); 再重载: HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(pWnd->m_hWnd == m_static.m_hWnd ) { pDC->SetBkColor(RGB(255,0,0)); return (HBRUSH)brush; } // TODO: Return a different brush if the default is not desired return hbr; }
在该窗口初始化时:
brush.CreateSolidBrush(RGB(255,0,0));
再重载:
HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here
if(pWnd->m_hWnd == m_static.m_hWnd )
{
pDC->SetBkColor(RGB(255,0,0));
return (HBRUSH)brush;
}
// TODO: Return a different brush if the default is not desired return hbr;
}
[email protected]