mfc 修改static 背景色

来源:互联网 发布:mac os 重装系统 u盘 编辑:程序博客网 时间:2024/05/22 12:06

在 ON_WM_CTLCOLOR 消息添加


HBRUSH CViewInit::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);


if ( pWnd->GetDlgCtrlID() == IDC_STATIC_RBG )
{
return CreateSolidBrush( theApp.m_RGB[0] ); //修改背景色
}
else if ( pWnd->GetDlgCtrlID() == IDC_STATIC_CODE )
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)::GetStockObject(NULL_BRUSH);//修改 背景为透明
}
return hbr;
}


参考

http://blog.csdn.net/m_wordplan/article/details/53856605

http://blog.csdn.net/lgstudyvc/article/details/51324206