设置窗体背景色,可是控件的背景色还是原来的灰色的,很难看,该如何修改
设置窗体背景色,可是控件的背景色还是原来的灰色的,很难看,该怎么修改?
BOOL CsssDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
// Create a pruple brush.
CBrush Brush (RGB (128 , 0 , 128) );
// Select the brush into the device context .
CBrush* pOldBrush=pDC->SelectObject(&Brush);
// Get the area that needs to be erased .
CRect reClip;
pDC->GetClipBox(&reClip);
//Paint the area.
pDC-> PatBlt (reClip.left , reClip.top , reClip.Width ( ) , reClip.Height( ) , PATCOPY );
//Unselect brush out of device context .
pDC->SelectObject(pOldBrush );
// Return nonzero to half fruther processing .
return TRUE;
//return CDialog::OnEraseBkgnd(pDC);
}
//*************************以上是设置窗体背景色的代码**********************************
------解决方案--------------------
重载OnCtlColor函数,在其内部设置控件的颜色为透明:pDC->SetBkMode(TRANSPARENT);
------解决方案--------------------
重载OnCtlColor(…),即WM_CTLCOLOR消息
BOOL CsssDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
// Create a pruple brush.
CBrush Brush (RGB (128 , 0 , 128) );
// Select the brush into the device context .
CBrush* pOldBrush=pDC->SelectObject(&Brush);
// Get the area that needs to be erased .
CRect reClip;
pDC->GetClipBox(&reClip);
//Paint the area.
pDC-> PatBlt (reClip.left , reClip.top , reClip.Width ( ) , reClip.Height( ) , PATCOPY );
//Unselect brush out of device context .
pDC->SelectObject(pOldBrush );
// Return nonzero to half fruther processing .
return TRUE;
//return CDialog::OnEraseBkgnd(pDC);
}
//*************************以上是设置窗体背景色的代码**********************************
------解决方案--------------------
重载OnCtlColor函数,在其内部设置控件的颜色为透明:pDC->SetBkMode(TRANSPARENT);
------解决方案--------------------
重载OnCtlColor(…),即WM_CTLCOLOR消息