在DLG中的onCtrColor使用
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
来设置控件的背景透明色,有两个问题:
1. 在DLG的onpaint中画图片背景,但窗体上的控件背景却不是DLG的背景,而是DLG启动前桌面为背景。
2. 控件背景透明,但如果有对话框如Messagebox把控件盖住后,关掉对话框后,遮盖的部分仍会留在那。都是因为对windows的绘图机制不熟,求高手指导~
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
来设置控件的背景透明色,有两个问题:
1. 在DLG的onpaint中画图片背景,但窗体上的控件背景却不是DLG的背景,而是DLG启动前桌面为背景。
2. 控件背景透明,但如果有对话框如Messagebox把控件盖住后,关掉对话框后,遮盖的部分仍会留在那。都是因为对windows的绘图机制不熟,求高手指导~
{
// Set the text color to red
pDC->SetTextColor(RGB(255, 0, 0)); // Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT); // Return handle to our CBrush object
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor != CTLCOLOR_DLG)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
// TODO: Return a different brush if the default is not desired
return hbr;
}