HexEdit/GridCtrl_src/GridCtrl.cpp
CCellRange CGridCtrl::GetVisibleNonFixedCellRange(LPRECT pRect /*=NULL*/, 
                                                  BOOL bForceRecalculation /*=FALSE*/)
{
    CRect rect;
    GetClientRect(rect);

    CCellID idTopLeft = GetTopleftNonFixedCell(bForceRecalculation);

    // calc bottom
    int bottom = GetFixedRowHeight();
	int i;
    for (i = idTopLeft.row; i < GetRowCount(); i++)
    {
        bottom += GetRowHeight(i);
        if (bottom >= rect.bottom)
        {
            bottom = rect.bottom;
            break;
        }
    }
    int maxVisibleRow = min(i, GetRowCount() - 1);

    // calc right
    int right = GetFixedColumnWidth();
    for (i = idTopLeft.col; i < GetColumnCount(); i++)
    {
        right += GetColumnWidth(i);
        if (right >= rect.right)
        {
            right = rect.right;
            break;
        }
    }
    int maxVisibleCol = min(i, GetColumnCount() - 1);
    if (pRect)
    {
        pRect->left = pRect->top = 0;
        pRect->right = right;
        pRect->bottom = bottom;
    }

    return CCellRange(idTopLeft.row, idTopLeft.col, maxVisibleRow, maxVisibleCol);
}
// This gets even partially visible cells

This gets even partially visible cells
This gets even partially visible cells
CCellRange CGridCtrl::GetVisibleNonFixedCellRange(LPRECT pRect , 
                                                  BOOL bForceRecalculation )
{
    CRect rect;
    GetClientRect(rect);
    CCellID idTopLeft = GetTopleftNonFixedCell(bForceRecalculation);
    int bottom = GetFixedRowHeight();
	int i;
    for (i = idTopLeft.row; i < GetRowCount(); i++)
    {
        bottom += GetRowHeight(i);
        if (bottom >= rect.bottom)
        {
            bottom = rect.bottom;
            break;
        }
    }
    int maxVisibleRow = min(i, GetRowCount() - 1);
    int right = GetFixedColumnWidth();
    for (i = idTopLeft.col; i < GetColumnCount(); i++)
    {
        right += GetColumnWidth(i);
        if (right >= rect.right)
        {
            right = rect.right;
            break;
        }
    }
    int maxVisibleCol = min(i, GetColumnCount() - 1);
    if (pRect)
    {
        pRect->left = pRect->top = 0;
        pRect->right = right;
        pRect->bottom = bottom;
    }
    return CCellRange(idTopLeft.row, idTopLeft.col, maxVisibleRow, maxVisibleCol);
}
CCellRange CGridCtrl :: GetVisibleNonFixedCellRange ( LPRECT pRect , BOOL bForceRecalculation ) { CRect rect ; GetClientRect ( rect ) ; CCellID idTopLeft = GetTopleftNonFixedCell ( bForceRecalculation ) ; int bottom = GetFixedRowHeight ( ) ; int i ; for ( i = idTopLeft . row ; i < GetRowCount ( ) ; i ++ ) { bottom += GetRowHeight ( i ) ; if ( bottom >= rect . bottom ) { bottom = rect . bottom ; break ; } } int maxVisibleRow = min ( i , GetRowCount ( ) - 1 ) ; int right = GetFixedColumnWidth ( ) ; for ( i = idTopLeft . col ; i < GetColumnCount ( ) ; i ++ ) { right += GetColumnWidth ( i ) ; if ( right >= rect . right ) { right = rect . right ; break ; } } int maxVisibleCol = min ( i , GetColumnCount ( ) - 1 ) ; if ( pRect ) { pRect -> left = pRect -> top = 0 ; pRect -> right = right ; pRect -> bottom = bottom ; } return CCellRange ( idTopLeft . row , idTopLeft . col , maxVisibleRow , maxVisibleCol ) ; }
This gets even partially visible cells
This gets even partially visible cells
/*=NULL*/ /*=FALSE*/ // calc bottom
 // calc right
