I use CListBox::SetItemData to store a pointer to some data in my ownerdrawn CListBox-derived class, and I'd like the listbox itself to keep track of it and free the memory when its no longer needed.
For that I'd need to be notified each time an item is deleted (including LB_RESETCONTENT and every possible other case where an item is deleted). Is there an event or events that I can handle to achieve that?
As its owner drawn with one of the LBS_OWNERDRAW*
styles you can look out for WM_DELETEITEM
;
Sent to the owner of a list box or combo box when the list box or combo box is destroyed or when items are removed by the
LB_DELETESTRING
,LB_RESETCONTENT
,CB_DELETESTRING
, orCB_RESETCONTENT
message. The system sends aWM_DELETEITEM
message for each deleted item