HexEdit/GridCtrl_src/GridCtrl.cpp
void CGridCtrl::ExpandRowsToFit(BOOL bExpandFixed /*=TRUE*/)
{
    if (bExpandFixed)
	{
		if (GetRowCount() <= 0) return;
	} 
	else
	{
		if (GetRowCount() <= GetFixedRowCount()) return;
	}

    EnableScrollBars(SB_VERT, FALSE); 

    CRect rect;
    GetClientRect(rect);

    int nFirstRow = (bExpandFixed)? 0 : GetFixedRowCount();

    int nNumRowsAffected = 0;
	int row;
    for (row = nFirstRow; row < GetRowCount(); row++)
    {
        if (m_arRowHeights[row] > 0)
            nNumRowsAffected++;
    }

    if (nNumRowsAffected <= 0)
        return;

    long virtualHeight = GetVirtualHeight();
    int nDifference = rect.Height() -(int) virtualHeight;
    int nRowAdjustment = nDifference / nNumRowsAffected;

    for (row = nFirstRow; row < GetRowCount(); row++)
    {
        if (m_arRowHeights[row] > 0)
            m_arRowHeights[row] += nRowAdjustment;
    }

    if (nDifference > 0)
    {
        int leftOver = nDifference % nNumRowsAffected;
        for (int nCount = 0, row = nFirstRow; 
             (row < GetRowCount()) && (nCount < leftOver); row++, nCount++)
        {
            if (m_arRowHeights[row] > 0)
                m_arRowHeights[row] += 1;
        }
    } 
    else 
    {
        int leftOver = (-nDifference) % nNumRowsAffected;
        for (int nCount = 0, row = nFirstRow; 
             (row < GetRowCount()) && (nCount < leftOver); row++, nCount++)
        {
            if (m_arRowHeights[row] > 0)
                m_arRowHeights[row] -= 1;
        }
    }

    Refresh();

    ResetScrollBars();
}
// Expands the rows to fit the screen space. If bExpandFixed is FALSE then fixed 
// rows will not be affected

Expands the rows to fit the screen space. If bExpandFixed is FALSE then fixed
rows will not be affected
Expands the rows to fit the screen space . If bExpandFixed is FALSE then fixed rows will not be affected
void CGridCtrl::ExpandRowsToFit(BOOL bExpandFixed )
{
    if (bExpandFixed)
	{
		if (GetRowCount() <= 0) return;
	} 
	else
	{
		if (GetRowCount() <= GetFixedRowCount()) return;
	}
    EnableScrollBars(SB_VERT, FALSE); 
    CRect rect;
    GetClientRect(rect);
    int nFirstRow = (bExpandFixed)? 0 : GetFixedRowCount();
    int nNumRowsAffected = 0;
	int row;
    for (row = nFirstRow; row < GetRowCount(); row++)
    {
        if (m_arRowHeights[row] > 0)
            nNumRowsAffected++;
    }
    if (nNumRowsAffected <= 0)
        return;
    long virtualHeight = GetVirtualHeight();
    int nDifference = rect.Height() -(int) virtualHeight;
    int nRowAdjustment = nDifference / nNumRowsAffected;
    for (row = nFirstRow; row < GetRowCount(); row++)
    {
        if (m_arRowHeights[row] > 0)
            m_arRowHeights[row] += nRowAdjustment;
    }
    if (nDifference > 0)
    {
        int leftOver = nDifference % nNumRowsAffected;
        for (int nCount = 0, row = nFirstRow; 
             (row < GetRowCount()) && (nCount < leftOver); row++, nCount++)
        {
            if (m_arRowHeights[row] > 0)
                m_arRowHeights[row] += 1;
        }
    } 
    else 
    {
        int leftOver = (-nDifference) % nNumRowsAffected;
        for (int nCount = 0, row = nFirstRow; 
             (row < GetRowCount()) && (nCount < leftOver); row++, nCount++)
        {
            if (m_arRowHeights[row] > 0)
                m_arRowHeights[row] -= 1;
        }
    }
    Refresh();
    ResetScrollBars();
}
void CGridCtrl :: ExpandRowsToFit ( BOOL bExpandFixed ) { if ( bExpandFixed ) { if ( GetRowCount ( ) <= 0 ) return ; } else { if ( GetRowCount ( ) <= GetFixedRowCount ( ) ) return ; } EnableScrollBars ( SB_VERT , FALSE ) ; CRect rect ; GetClientRect ( rect ) ; int nFirstRow = ( bExpandFixed ) ? 0 : GetFixedRowCount ( ) ; int nNumRowsAffected = 0 ; int row ; for ( row = nFirstRow ; row < GetRowCount ( ) ; row ++ ) { if ( m_arRowHeights [ row ] > 0 ) nNumRowsAffected ++ ; } if ( nNumRowsAffected <= 0 ) return ; long virtualHeight = GetVirtualHeight ( ) ; int nDifference = rect . Height ( ) - ( int ) virtualHeight ; int nRowAdjustment = nDifference / nNumRowsAffected ; for ( row = nFirstRow ; row < GetRowCount ( ) ; row ++ ) { if ( m_arRowHeights [ row ] > 0 ) m_arRowHeights [ row ] += nRowAdjustment ; } if ( nDifference > 0 ) { int leftOver = nDifference % nNumRowsAffected ; for ( int nCount = 0 , row = nFirstRow ; ( row < GetRowCount ( ) ) && ( nCount < leftOver ) ; row ++ , nCount ++ ) { if ( m_arRowHeights [ row ] > 0 ) m_arRowHeights [ row ] += 1 ; } } else { int leftOver = ( - nDifference ) % nNumRowsAffected ; for ( int nCount = 0 , row = nFirstRow ; ( row < GetRowCount ( ) ) && ( nCount < leftOver ) ; row ++ , nCount ++ ) { if ( m_arRowHeights [ row ] > 0 ) m_arRowHeights [ row ] -= 1 ; } } Refresh ( ) ; ResetScrollBars ( ) ; }
Expands the rows to fit the screen space.
Expands the rows to fit the screen space .
/*=TRUE*/