vc static控件背景设置成透明(其他控件也可以)

来源:互联网 发布:安徽网站seo 编辑:程序博客网 时间:2024/05/19 05:02
假设你的static控件ID为IDC_STATIC1: 然后重载对话框的WM_CTLCOLOR消息: 在OnCtlColor中添加如下代码: HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here switch(pWnd->GetDlgCtrlID()) { case IDC_STATIC1: pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(0,0,0)); return (HBRUSH)GetStockObject(HOLLOW_BRUSH); default: break; } // TODO: Return a different brush if the default is not desired return hbr; }