![]() |
Moving rows |
Post Reply
|
| Author | |
rock
Groupie
Joined: 27 October 2005 Status: Offline Points: 19 |
Post Options
Thanks(0)
Quote Reply
Topic: Moving rowsPosted: 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? |
|
![]() |
|
sserge
Moderator Group
Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
rock
Groupie
Joined: 27 October 2005 Status: Offline Points: 19 |
Post Options
Thanks(0)
Quote Reply
Posted: 10 July 2006 at 11:58am |
|
Serge,
That appears to have done it. It works fine now. Thanks |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |