Q: How to correctly delete items from a CListCtrl?
A: Unlike the 'HTREEITEM' values returned from 'CTreeCtrl::InsertItem()', the integer values returned from 'CListCtrl::InsertItem()' aren't stable. In short, this means that you shouldn't store them anywhere. If you need to find an entry again, it's probably best to simply put something useful in 'LVITEM::lParam', and search for it using 'CListCtrl::GetNextItem()'.
Having said that, one can use the following piece of code to correctly delete items from a CListCtrl:
Note: Most of the material in this article is taken from codeguru.com