Using MFC I sub-classed the CListBox
(CBCGPListBox – for themes) to send selection change notifications when items are deleted. This works fine for all items except the very last item deleted from the list box (list box becomes empty). In that case the DeleteItem()
virtual function is NOT called. It seems strange to me that it wouldn’t be called? Is there some other message or virtual function that deals with that?
class CMyListBox : public CBCGPListBox
{
virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct)
{
__super::DeleteItem(lpDeleteItemStruct);
GetParent()->PostMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_SELCHANGE), (LPARAM)m_hWnd);
};
};