Moving rows
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=4558
Printed Date: 31 October 2024 at 9:20pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Moving rows
Posted By: rock
Subject: Moving rows
Date Posted: 07 July 2006 at 4:58pm
I have a dialog box that contains a Report Control and a CSpinButtonCtrl. I use the spin control to successfully
move rows up or down within the Report control. However, when I
exit the dialog box I get an assertion error in the CXTPReportRows
destructor during the call to CXTPReportRows::Clear().
Specifically to the line pRow->InternalRelease();
My code for moving rows is:
void CSortReportDlg::OnDeltaposReportSpin(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
int number_rows = wndReport.GetRows()->GetCount();
int cur_item = wndReport.GetFocusedRow();
if (pNMUpDown->iDelta > 0 && cur_item >= 0) // Move Up
{
if (cur_item == 0 || cur_item >= number_rows)
return;
CXTPReportRow *pRow = wndReport.GetRows()->GetAt(cur_item);
if (pRow)
{
wndReportGetRows()->RemoveAt(cur_item);
wndReportGetRows()->InsertAt(cur_item - 1, pRow);
}
}
else if (pNMUpDown->iDelta < 0 &&
cur_item >= 0 && cur_item < (number_rows - 1)) //
Move Down
{
if (number_rows == 0 || cur_item == number_rows || cur_item >= number_rows-1)
return;
CXTPReportRow *pRow = wndReport.GetRows()->GetAt(cur_item);
if (pRow)
{
wndReportGetRows()->RemoveAt(cur_item);
wndReportGetRows()->InsertAt(cur_item + 1, pRow);
}
}
*pResult = 0;
}
Have I missed some other function call I must make after moving the rows?
|
Replies:
Posted By: sserge
Date Posted: 09 July 2006 at 8:57am
Hi,
RemoveAt calls InternalRelease for a removed row, unlike InsertAt, which assumes recently created row object. So far, it looks like you have to add pRow->InternalAddRef(); as a first operation in if (pRow) {...
-- WBR, Serge
|
Posted By: rock
Date Posted: 10 July 2006 at 11:58am
Serge,
That appears to have done it. It works fine now.
Thanks
|
|