CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: CListControl

  1. #1
    Join Date
    Jul 1999
    Posts
    12

    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





  2. #2
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658

    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 )


  3. #3
    Join Date
    Nov 1999
    Location
    Dresden / Germoney
    Posts
    1,402

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured