mfc怎么设置static背景色和控件颜色一样
发布网友
发布时间:2023-11-26 21:10
我来回答
共1个回答
热心网友
时间:2024-11-03 03:15
在头文件里定义一个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;
}