Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - CXTPReportControl::GetReportAreaRows: wrong result
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPReportControl::GetReportAreaRows: wrong result

 Post Reply Post Reply
Author
Message
leo_12 View Drop Down
Groupie
Groupie
Avatar

Joined: 12 April 2005
Location: Germany
Status: Offline
Points: 17
Post Options Post Options   Thanks (1) Thanks(1)   Quote leo_12 Quote  Post ReplyReply Direct Link To This Post Topic: CXTPReportControl::GetReportAreaRows: wrong result
    Posted: 05 June 2012 at 8:18am
Hi,
 
I have some trouble to get the best fit column width of the tree column in an virtual mode ReportControl.
 
As documentation says, CXTPReportControl::GetReportAreaRows should return the number of currently visible rows between nStartRow and the bottom of the current view.
 
In my case I have 2 rows in large view so they are all visible. The function returns 1. Should the nStartRow be included in the result or not?
 
If not, then in CXTPReportControl::OnGetColumnDataBestFitWidth the result of GetReportAreaRows in the local variable nVisibleRows should be incremented by 1. Otherwise the width of the last item is not considered in the calculation of the width.

Kind regards

Heiko





Product: Xtreme ToolkitPro version 15.0.2 / 15.2.1.0423

Platform: Windows 7 64 Bit

Language: C++
Back to Top
franji1 View Drop Down
Groupie
Groupie
Avatar

Joined: 28 June 2005
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote franji1 Quote  Post ReplyReply Direct Link To This Post Posted: 25 October 2023 at 10:01am
(13.2.1)  I just saw this behavior in my implementation of a "Best Fit All" on my virtual report control.  If the last displayable row is the "widest" for a column, the Best Fit clips it (next "widest" is much narrower).  If I scroll down so that another (yet narrower) row is in the viewport for the control, the "Best Fit All" works as expected!

11 years later - not too late Handshake

I've been trying to fix it - thought it was in my code!
XTP 13.3
migrating to XTP 20.3
Back to Top
franji1 View Drop Down
Groupie
Groupie
Avatar

Joined: 28 June 2005
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote franji1 Quote  Post ReplyReply Direct Link To This Post Posted: 25 October 2023 at 10:34am
I just saw that CXTPReportControl::OnGetItemsCaptionMaxWidth is virtual.  I can override it and fix it that way.

EDIT 13.3
int CXTPReportControl::GetReportAreaRows(int nStartRow, BOOL bMoveDown)
{
...
//return bMoveDown ? m_pRows->GetCount() - nStartRow : nStartRow;
return bMoveDown ? m_pRows->GetCount() - nStartRow - 1: nStartRow; //-this is better way!
}

The code looks WRONG.  It does all this work to determine what is the last row (in the local var i), yet the return statement does not take into account any of that work (the commented out return is theirs).

There should be an i in the return statement somewhere???
XTP 13.3
migrating to XTP 20.3
Back to Top
franji1 View Drop Down
Groupie
Groupie
Avatar

Joined: 28 June 2005
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote franji1 Quote  Post ReplyReply Direct Link To This Post Posted: 25 October 2023 at 10:55am
The code (GetReportAreaRows) appears to still be busted in 20.x

Maybe I do not understand what this method is supposed to do (why all that work without doing anything with it?)
XTP 13.3
migrating to XTP 20.3
Back to Top
franji1 View Drop Down
Groupie
Groupie
Avatar

Joined: 28 June 2005
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote franji1 Quote  Post ReplyReply Direct Link To This Post Posted: 25 October 2023 at 11:22am
I "overrode" OnGetItemsCaptionMaxWidth

int CMemViewReportCtrl::OnGetItemsCaptionMaxWidth(CDC* pDC, CXTPReportRows* pRows, CXTPReportColumn* pColumn, int nStartRow /* = 0 */, int nRowsCount /* = -1 */)
{
// OBOB in XTP in reporting # of visible rows (in virtual mode???)
if ((nRowsCount >= 0) /* && IsVirtualMode()*/ && (nStartRow >= 0))
{
// if I have 10 rows 0..9, the row count is still 10, not 9!
if (nRowsCount == (GetRows()->GetCount() - nStartRow - 1))
{
//HASSERT(false);
nRowsCount++;
}
}
const int nWidth = BASE_CLASS::OnGetItemsCaptionMaxWidth(pDC, pRows, pColumn, nStartRow, nRowsCount);
return nWidth;
}

XTP 13.3
migrating to XTP 20.3
Back to Top
franji1 View Drop Down
Groupie
Groupie
Avatar

Joined: 28 June 2005
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote franji1 Quote  Post ReplyReply Direct Link To This Post Posted: 25 October 2023 at 11:31am
FYI to duplicate the bug in GetReportAreaRows() (or the bug could be in OnGetItemsCaptionMaxWidth, depending upon if GetReportAreaRows() behavior is actually "correct"),
stick the widest data (by far) in the last row of your RC in one of the columns.

View your RC with the last row NOT visible.  Resize Autosize the column, and it works correctly.  Scroll down so that this last row is visible.  Resize  Autosize that column again and it does not take into account the width of that last row.

It may only be an issue in virtual mode (the resize  autosize behavior, not the GetReportAreaRows issue)
XTP 13.3
migrating to XTP 20.3
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.