Hello,
There is a bug in code, columns expand/collapse doesn't work.
Your code (Codejock MFC TookKit Pro version 15.2.1):
void CXTPReportColumn::SetExpanded(BOOL bExpanded) { m_bExpanded = bExpanded; int nCnt = m_pColumns->GetCount(); int iN = GetNextVisualBlock(); int iVs = GetVisibleIndex(); CXTPReportColumn* pCol = NULL; for (int iC = 0; iC < nCnt; iC++) { pCol = m_pColumns->GetAt(nCnt - iC - 1); if (pCol) { if (bExpanded) { int iVc = pCol->GetVisibleIndex(); if (iVc == -1) continue; if (iN > 0 && iVc > iVs && iVc <= iVs + iN) pCol->SetVisible(FALSE); else if (iN < 0 && iVc < iVs && iVc >= iVs + iN) pCol->SetVisible(FALSE); } else { int iVc = pCol->GetOldVisibleIndex(); if (iVc == -1) continue; if (iN > 0 && iVc > iVs && iVc <= iVs + iN) pCol->SetVisible(TRUE); //else if (iN < 0 && iVc <= iVs + 1 && iVc >= iVs + iN) else if (iN < 0 && iVc <= iVs + 2 && iVc >= iVs + iN) pCol->SetVisible(TRUE); } } } }
My fix:
int CMyXTPReportColumn::SetExpanded(BOOL bExpanded) { // Fixes a bug in Codejock version 15.2.1 - CXTPReportColumn::SetExpanded(...) m_bExpanded = bExpanded; CXTPReportControl* pControl = GetControl(); if (pControl) { int nNextVisualBlock = GetNextVisualBlock(); if (nNextVisualBlock != 0) { int nItemIndex = GetItemIndex(); int nStart; int nEnd;
if (nNextVisualBlock < 0) { nStart = nItemIndex + nNextVisualBlock; nEnd = nItemIndex; } else { nStart = nItemIndex + 1; nEnd = nItemIndex + nNextVisualBlock + 1; }
CXTPReportColumn* pColumnExp; for (int i=nItemIndex + nNextVisualBlock; i < nItemIndex; i++) { pColumnExp = pControl->FFindColumn(i); // Find column by internal index instead of position if (pColumnExp) pColumnExp->SetVisible(bExpanded); } }
pControl->AdjustLayout(); pControl->AdjustScrollBars(); } }
Moreover, beware of initial state of expand/collapse that isn't also correctly set. I let you do that fix by yourself.
Regards
------------- Sergio
|