1、静态文本框的背景与对话框的背景是一样的,这里需要将其设置为透明的;
2、在对话框类中响应WM_CtlCOLOR消息;
3、在OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 函数中添加如下代码:
HBRUSH CPictureDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
//将静态文本框设置为透明
if (CTLCOLOR_STATIC == nCtlColor)
{
pDC->SetBkMode(TRANSPARENT);
//返回一个空画刷
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
// TODO: Return a different brush if the default is not desired
return hbr;
}