BOOL CYinView::OnEraseBkgnd(CDC* pDC) { // Create a pruple brush. CBrush brush(RGB(128,192,192)); // Select the brush into the device context . CBrush* pOldBrush=pDC->SelectObject(&brush); // Get the area that needs to be erased . CRect rc; pDC->GetClipBox(&rc); //Paint the area. pDC->PatBlt(rc.left,rc.top,rc.Width(),rc.Height(),PATCOPY); //Unselect brush out of device context . pDC->SelectObject(pOldBrush); // Return nonzero to half fruther processing . return TRUE; ///**/ return CFormView::OnEraseBkgnd(pDC); }
{
RECT rect;
CBrush br;
br.CreateSolidBrush(RGB(0,0,0)); //创建一个刷子,颜色为黑色
GetClientRect( &rect ); //取得客户区边界
pDC->FillRect( &rect, &br ); //用刚才创建的刷子画客户区 return true;
// return CView::OnEraseBkgnd(pDC); //这一句要注释掉
}
不是用消息响应的方法,这方法太笨
有没有改变背景的函数,就像改变填充色的setbkcolor?
m_CBkBrush.CreateSolidBrush(RGB(0, 85, 206));
...
OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
if(nCtlColor ==CTLCOLOR_DLG || nCtlColor ==CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(255, 255, 255)/*GetSysColor(COLOR_HIGHLIGHTTEXT)*/) ;
pDC->SetBkMode( TRANSPARENT );
return (HBRUSH) m_CBkBrush.GetSafeHandle ();
}
成你需要的背景刷子!
我只是想知道这儿到底有多少高手,看来很令我失望呀
这里的确有很多高手,抱着书上的死东西没有好处,多想想程序的具体实现吧。前辈开发了很多关于界面的东西,对于这些我们拿来用就是了。
难道你没用过?建议你还是好好看书吧,学习可不能玩虚的
{
// Create a pruple brush.
CBrush brush(RGB(128,192,192));
// Select the brush into the device context .
CBrush* pOldBrush=pDC->SelectObject(&brush);
// Get the area that needs to be erased .
CRect rc;
pDC->GetClipBox(&rc);
//Paint the area.
pDC->PatBlt(rc.left,rc.top,rc.Width(),rc.Height(),PATCOPY);
//Unselect brush out of device context .
pDC->SelectObject(pOldBrush);
// Return nonzero to half fruther processing .
return TRUE;
///**/ return CFormView::OnEraseBkgnd(pDC);
}