DWORD CItemList::GetScrollLineMax(LPRECT pRect) { DWORD lpp = GetLinesPerPage( pRect ); DWORD ucl = GetUncollapsedLines(); // Will all the lines fit on the page? if ( lpp >= ucl ) return 0; // Return number of lines that don't fit on the page return ucl - lpp; }
void CDrawGrid::CalcPages() /* ============================================================ Function : CDrawGrid::CalcPages Description : Calculates the start and end line for each page of the grid. Normally, this is just calculated from the number of line that fits on each page, but as the grid can contain page breaks as well, we need to do it this way. Access : Private Return : void Parameters : none Usage : The function is only called internally. ============================================================*/ { int max = GetLines(); int pagelength = GetLinesPerPage(); int pagecounter = 0; int oldEndLine = 0; m_pages.RemoveAll(); for( int t = 0 ; t < max ; t++ ) { // We walk through each line, checking if we have reached // the end of the page, or if the line contains a page // break in any column. pagecounter++; if( IsPagebreak( m_data[ t ] ) ) { CPageLength* pgl = new CPageLength; pgl->m_startLine = oldEndLine; pgl->m_endLine = t; m_pages.Add( pgl ); oldEndLine = t + 1; pagecounter = 0; } else if( pagecounter > pagelength ) { CPageLength* pgl = new CPageLength; pgl->m_startLine = oldEndLine; pgl->m_endLine = t + 1; m_pages.Add( pgl ); oldEndLine = t + 1; pagecounter = 0; } } if( pagecounter ) { // If we have some lines of data // left for the last page... CPageLength* pgl = new CPageLength; pgl->m_startLine = oldEndLine; pgl->m_endLine = max; m_pages.Add( pgl ); } }