HexEdit/GridCtrl_src/GridCtrl.cpp
void CGridCtrl::EraseBkgnd(CDC* pDC)
{
    CRect  VisRect, ClipRect, rect;
    CBrush FixedRowColBack(GetDefaultCell(TRUE, TRUE)->GetBackClr()),
           FixedRowBack(GetDefaultCell(TRUE, FALSE)->GetBackClr()),
           FixedColBack(GetDefaultCell(FALSE, TRUE)->GetBackClr()),
           TextBack(GetDefaultCell(FALSE, FALSE)->GetBackClr());
    CBrush Back(GetGridBkColor()); 
    //CBrush Back(GetTextBkColor());

    if (pDC->GetClipBox(ClipRect) == ERROR)
        return;
    GetVisibleNonFixedCellRange(VisRect);

    int nFixedColumnWidth = GetFixedColumnWidth();
    int nFixedRowHeight = GetFixedRowHeight();

    // Draw Fixed row/column background
    if (ClipRect.left < nFixedColumnWidth && ClipRect.top < nFixedRowHeight)
        pDC->FillRect(CRect(ClipRect.left, ClipRect.top, 
                      nFixedColumnWidth, nFixedRowHeight),
                      &FixedRowColBack);

    // Draw Fixed columns background
    if (ClipRect.left < nFixedColumnWidth && ClipRect.top < VisRect.bottom)
        pDC->FillRect(CRect(ClipRect.left, ClipRect.top, 
                      nFixedColumnWidth, VisRect.bottom),
                      &FixedColBack);

    // Draw Fixed rows background
    if (ClipRect.top < nFixedRowHeight && 
        ClipRect.right > nFixedColumnWidth && ClipRect.left < VisRect.right)
        pDC->FillRect(CRect(nFixedColumnWidth-1, ClipRect.top,
                      VisRect.right, nFixedRowHeight),
                      &FixedRowBack);

    // Draw non-fixed cell background
    if (rect.IntersectRect(VisRect, ClipRect)) 
    {
        CRect CellRect(max(nFixedColumnWidth, rect.left), 
                       max(nFixedRowHeight, rect.top),
                       rect.right, rect.bottom);
        pDC->FillRect(CellRect, &TextBack);
    }

    // Draw right hand side of window outside grid
    if (VisRect.right < ClipRect.right) 
        pDC->FillRect(CRect(VisRect.right, ClipRect.top, 
                      ClipRect.right, ClipRect.bottom),
                      &Back);

    // Draw bottom of window below grid
    if (VisRect.bottom < ClipRect.bottom && ClipRect.left < VisRect.right) 
        pDC->FillRect(CRect(ClipRect.left, VisRect.bottom,
                      VisRect.right, ClipRect.bottom),
                      &Back);
}
// Custom background erasure. This gets called from within the OnDraw function,
// since we will (most likely) be using a memory DC to stop flicker. If we just
// erase the background normally through OnEraseBkgnd, and didn't fill the memDC's
// selected bitmap with colour, then all sorts of vis problems would occur

Custom background erasure. This gets called from within the OnDraw function,
since we will (most likely) be using a memory DC to stop flicker. If we just
erase the background normally through OnEraseBkgnd, and didn't fill the memDC's
selected bitmap with colour, then all sorts of vis problems would occur
Custom background erasure . This gets called from within the OnDraw function since we will ( most likely ) be using a memory DC to stop flicker . If we just erase the background normally through OnEraseBkgnd and didn ' t fill the memDC ' s selected bitmap with colour then all sorts of vis problems would occur
void CGridCtrl::EraseBkgnd(CDC* pDC)
{
    CRect  VisRect, ClipRect, rect;
    CBrush FixedRowColBack(GetDefaultCell(TRUE, TRUE)->GetBackClr()),
           FixedRowBack(GetDefaultCell(TRUE, FALSE)->GetBackClr()),
           FixedColBack(GetDefaultCell(FALSE, TRUE)->GetBackClr()),
           TextBack(GetDefaultCell(FALSE, FALSE)->GetBackClr());
    CBrush Back(GetGridBkColor()); 
    if (pDC->GetClipBox(ClipRect) == ERROR)
        return;
    GetVisibleNonFixedCellRange(VisRect);
    int nFixedColumnWidth = GetFixedColumnWidth();
    int nFixedRowHeight = GetFixedRowHeight();
    if (ClipRect.left < nFixedColumnWidth && ClipRect.top < nFixedRowHeight)
        pDC->FillRect(CRect(ClipRect.left, ClipRect.top, 
                      nFixedColumnWidth, nFixedRowHeight),
                      &FixedRowColBack);
    if (ClipRect.left < nFixedColumnWidth && ClipRect.top < VisRect.bottom)
        pDC->FillRect(CRect(ClipRect.left, ClipRect.top, 
                      nFixedColumnWidth, VisRect.bottom),
                      &FixedColBack);
    if (ClipRect.top < nFixedRowHeight && 
        ClipRect.right > nFixedColumnWidth && ClipRect.left < VisRect.right)
        pDC->FillRect(CRect(nFixedColumnWidth-1, ClipRect.top,
                      VisRect.right, nFixedRowHeight),
                      &FixedRowBack);
    if (rect.IntersectRect(VisRect, ClipRect)) 
    {
        CRect CellRect(max(nFixedColumnWidth, rect.left), 
                       max(nFixedRowHeight, rect.top),
                       rect.right, rect.bottom);
        pDC->FillRect(CellRect, &TextBack);
    }
    if (VisRect.right < ClipRect.right) 
        pDC->FillRect(CRect(VisRect.right, ClipRect.top, 
                      ClipRect.right, ClipRect.bottom),
                      &Back);
    if (VisRect.bottom < ClipRect.bottom && ClipRect.left < VisRect.right) 
        pDC->FillRect(CRect(ClipRect.left, VisRect.bottom,
                      VisRect.right, ClipRect.bottom),
                      &Back);
}
void CGridCtrl :: EraseBkgnd ( CDC * pDC ) { CRect VisRect , ClipRect , rect ; CBrush FixedRowColBack ( GetDefaultCell ( TRUE , TRUE ) -> GetBackClr ( ) ) , FixedRowBack ( GetDefaultCell ( TRUE , FALSE ) -> GetBackClr ( ) ) , FixedColBack ( GetDefaultCell ( FALSE , TRUE ) -> GetBackClr ( ) ) , TextBack ( GetDefaultCell ( FALSE , FALSE ) -> GetBackClr ( ) ) ; CBrush Back ( GetGridBkColor ( ) ) ; if ( pDC -> GetClipBox ( ClipRect ) == ERROR ) return ; GetVisibleNonFixedCellRange ( VisRect ) ; int nFixedColumnWidth = GetFixedColumnWidth ( ) ; int nFixedRowHeight = GetFixedRowHeight ( ) ; if ( ClipRect . left < nFixedColumnWidth && ClipRect . top < nFixedRowHeight ) pDC -> FillRect ( CRect ( ClipRect . left , ClipRect . top , nFixedColumnWidth , nFixedRowHeight ) , & FixedRowColBack ) ; if ( ClipRect . left < nFixedColumnWidth && ClipRect . top < VisRect . bottom ) pDC -> FillRect ( CRect ( ClipRect . left , ClipRect . top , nFixedColumnWidth , VisRect . bottom ) , & FixedColBack ) ; if ( ClipRect . top < nFixedRowHeight && ClipRect . right > nFixedColumnWidth && ClipRect . left < VisRect . right ) pDC -> FillRect ( CRect ( nFixedColumnWidth - 1 , ClipRect . top , VisRect . right , nFixedRowHeight ) , & FixedRowBack ) ; if ( rect . IntersectRect ( VisRect , ClipRect ) ) { CRect CellRect ( max ( nFixedColumnWidth , rect . left ) , max ( nFixedRowHeight , rect . top ) , rect . right , rect . bottom ) ; pDC -> FillRect ( CellRect , & TextBack ) ; } if ( VisRect . right < ClipRect . right ) pDC -> FillRect ( CRect ( VisRect . right , ClipRect . top , ClipRect . right , ClipRect . bottom ) , & Back ) ; if ( VisRect . bottom < ClipRect . bottom && ClipRect . left < VisRect . right ) pDC -> FillRect ( CRect ( ClipRect . left , VisRect . bottom , VisRect . right , ClipRect . bottom ) , & Back ) ; }
Custom background erasure.
Custom background erasure .
//CBrush Back(GetTextBkColor());
 // Draw Fixed row/column background
 // Draw Fixed columns background
 // Draw Fixed rows background
 // Draw non-fixed cell background
 // Draw right hand side of window outside grid
 // Draw bottom of window below grid
