在多文档程序中,我生成的分割窗口,其中一个窗口中建立的是滚动视图,如何改变视图默认的白色背景色为其他色,期求帮助!!!谢谢!

解决方案 »

  1.   

    BOOL CMyScrollView::OnEraseBkgnd(CDC* pDC)
    {
        // Set brush to desired background color
        CBrush backBrush(RGB(192, 192, 192));    // Save the old brush
        CBrush* pOldBrush = pDC->SelectObject(&backBrush);    // Get the current clipping boundary
        CRect rect;
        pDC->GetClipBox(&rect);    // Erase the area needed
        pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),
             PATCOPY);    pDC->SelectObject(pOldBrush); // Select the old brush back
        return TRUE;  // message handled
    }
      

  2.   

    BOOL CWPCEToolsView::OnEraseBkgnd(CDC* pDC)//改变WPCEToolsView背景色 
    {
    // TODO: Add your message handler code here and/or call default
    CBrush Brush (RGB(58,110,165));//生成一兰色刷子
        // Select the brush into the device context . 
        CBrush* pOldBrush = pDC->SelectObject(&Brush); 
        // Get the area that needs to be erased . 
        CRect rect; 
        pDC->GetClipBox(&rect); 
        //Paint the area. 
        pDC->PatBlt(rect.left,rect.top,rect.Width(),rect.Height(),PATCOPY); 
        //Unselect brush out of device context . 
        pDC->SelectObject (pOldBrush ); 
        // Return nonzero to half fruther processing . 
    return TRUE;
    return CView::OnEraseBkgnd(pDC);
    }