-
CListControl
Hi All,
I have a doubt regarding the list control Deleteitem() and DeleteAllItem()s.
If I call DeleteItem() or DeleteAllItems(), Is list control going to delete associated item that's set by SetItemData().
Consider the following the situation,
Myrec *myRec = new Myrec();
// do some caluclations and fill Myrec.
// Add to list control
LVITEM pItem;
pItem.iItem = count;//lCount-1;
pItem.iSubItem = 0;
pItem.mask = LVIF_TEXT | LVIF_PARAM;
pItem.pszText = myRec->Name;
myCtrl.InsertItem( &pItem );
myCtrl.SetItemText(count, 1,myRec->ID;
myCtrl.SetItemData(count,(LPARAM)myRec);
After some time If I call myCtrl.DeleteAllites(), Is it going to delete the associated item myRec pointer(in heap) along with each row in list control?
Or do I need to store all my qrec pointers in a separate list while adding to list control, and delete them explicitly????
Thanks and Regards,
Ramana
-
Re: CListControl
No, CListCtrl definitely doesn't delete your MyRec pointers, because it doesn't know what to do and how. You have to delete them by yourself before DeleteAllItems via call GetItemData in a loop( just if you need to delete them )
-
Re: CListControl
Hi,
List Ctrl sends an LVN_DELETEITEM, and LVN_DELETEALLITEMS notifications when an item is deleted, so typically you would delete the myRect there.
Peter