BOOL CQisiyixiang112View::OnEraseBkgnd(CDC* pDC) 
{
// TODO: Add your message handler code here and/or call default
pDC->SetBkColor(RGB(255,0,0));
return CView::OnEraseBkgnd(pDC);
}
函数不管用啊?

解决方案 »

  1.   

    你要设置view视图的背景吗?
    你可以在view视图类中添加一个CBrush brush;在view类的构造函数中初始化你想要的颜色,比如:
    brush.CreateSolidBrush(RGB(255, 0, 0));添加view类的WM_CREATE消息响应函数,在OnCreate函数的return 0;语句之前加入如下语句即可:
    SetClassLong(m_hWnd, GCL_HBRBACKGROUND, (LONG)brush.m_hObject);
      

  2.   

    俺记得SetBkColor是输出文字时的文字背景,你想改变整个窗口的背景不行吧。
      

  3.   

    好像应该这样
    BOOL CQisiyixiang112View::OnEraseBkgnd(CDC* pDC) 

      // TODO: Add your message handler code here and/or call default 
      CBrush brush;
      brush.CreateSolidBrush( RGB(255,0,0) );
      CRect rect;
      GetClientRect(&rect);
      pDC->FillRect( &rect, &brush );
      return CView::OnEraseBkgnd(pDC); 

      

  4.   


    BOOL CTestView::OnEraseBkgnd(CDC* pDC) { CRect rect; CBrush brush; brush.CreateSolidBrush(GetDocument()->GetViewBkColor()); pDC->GetClipBox(rect); pDC->FillRect(rect,&brush); return true; }