NULL_BRUSH 或HOLLOW_BRUSH和GetStockObject函数
备注:HOLLOW_BRUSH等价于NULL_BRUSH,都代表透明化刷
HGDIOBJ GetStockObject( __in int fnObject)
参数:fnObject代表笔或者刷的类型,可以参看MSDN
返回值:返回一个GDIOBJ对象的句柄。根据需要转换成笔/刷的句柄,
如:HBRUSH(GetStockObject(HOLLOW_BRUSH));
实例应用:一个透明的背景的编辑框
HBRUSH CBackimageDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr =CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch(nCtlColor)
{
case CTLCOLOR_STATIC: //对所有静态文本控件的设置
{
pDC->SetBkMode(TRANSPARENT);//设置背景为透明 pDC->SetTextColor(RGB(0,0,0)); //设置字体颜色
returnHBRUSH(GetStockObject(HOLLOW_BRUSH)); // 必须
}
case CTLCOLOR_EDIT: //对所有编辑框控件的设置
{
pDC->SetBkMode(TRANSPARENT);//设置背景为透明 pDC->SetTextColor(RGB(0,0,0)); //设置字体颜色
returnHBRUSH(GetStockObject(HOLLOW_BRUSH)); // 必须
}
default:
returnCDialog::OnCtlColor(pDC,pWnd, nCtlColor);
}
return hbr;
}
效果:
http://blog.csdn.net/qq2399431200/article/details/10991917