Ejemplo n.º 1
0
int CDocStructRecordItem::GetReportAreaRows(CXTPReportControl *pReportControl, int nStartRow, BOOL bMoveDown) {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    int nDirection = bMoveDown ? +1 : -1;
    int top = pReportControl->GetReportRectangle().top;
    CClientDC dc(pReportControl);
    int nHeaderWidth = pReportControl->GetReportHeader()->GetWidth();

    for (int i = nStartRow; (i < pReportControl->GetRows()->GetCount() && i >= 0); i += nDirection) {
        CXTPReportRow* pRow = pReportControl->GetRows()->GetAt(i);
        ASSERT(pRow);
        if (!pRow) {
            continue;
        }
        int rowHeight = pRow->GetHeight(&dc, nHeaderWidth);
        if (top + rowHeight > pReportControl->GetReportRectangle().bottom 
            && i + 1 <= pReportControl->GetRows()->GetCount()) {
            return bMoveDown ? i - nStartRow  + 1 : nStartRow - i + 1;
        } else if (top + rowHeight > pReportControl->GetReportRectangle().bottom) {
            return bMoveDown ? i - nStartRow : nStartRow - i;
        }
        top += rowHeight;
    }

    return bMoveDown ? pReportControl->GetRows()->GetCount() - nStartRow : nStartRow;
}