Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - [not bug] Report Control MoveRecord bug
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic Closed[not bug] Report Control MoveRecord bug

 Post Reply Post Reply
Author
Message
jmarcosf View Drop Down
Groupie
Groupie


Joined: 22 June 2006
Status: Offline
Points: 27
Direct Link To This Post Topic: [not bug] Report Control MoveRecord bug
    Posted: 29 June 2015 at 2:35pm
I think there is a bug on MoveRecord() method on CXTPReportRecords class.
I commented out on source code below.

void CXTPReportRecords::MoveRecord(int nIndex, CXTPReportRecord* pRecord, BOOL bUpdateIndexes)
{
     if (nIndex < 0)
          nIndex = 0;

     if (nIndex > GetCount())
          nIndex = GetCount();

     if (pRecord)
     {
          int nRecordIndex = pRecord->GetIndex();

          if (nRecordIndex == nIndex)
               return;

          if (GetAt(nRecordIndex) == pRecord)
          {
               if (nRecordIndex < nIndex)          // I think this two sentences
                    nIndex--;                                // do not allow to move any record
                                                                   // one line down
               if (nRecordIndex == nIndex)       // Maybe I am wrong but
                    return;                                   // removing them it works fine for me
                                                                  // when I call it with index = current record index + 1
               m_arrRecords.RemoveAt(nRecordIndex);
               m_arrRecords.InsertAt(nIndex, pRecord);

               if (bUpdateIndexes)
                    UpdateIndexes();
          }
     }
}

Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Direct Link To This Post Posted: 29 June 2015 at 3:55pm
Hi Jorge,

Logic of MoveRecord(nIndex, pRecord) is move pRecord to place BEFORE record with index nIndex. We follow this logic in other places in code, and we are not going to change MoveRecord().

If you delete those two conditions then method will work incorrect.
If nIndex is greater than index of pRecord
then pRecord will be placed AFTER record with nIndex
else
then pRecord will be placed BEFORE record with nIndex


Regards,
Oleksandr Lebed
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.