Long time no writing essays, talk about today in the debug process encountered problems:
CListBox (list box), CListCtrl (Report Control), CTreeCtrl (for controls), CComboBox (combo box) have two of these functions: SetItemData and GetItemData, It is convenient to use these two functions to bind objects or data structures to these controls.
In the debug process, encountered the use of CListCtrl control and CTreeCtrl, double-click the tree node to get the tree node data, pressed into the Listctrl control room, which involves the filtering function of the tree control, my filter function is to use the tree reconstruction to build a new tree.
1. The tree node obtained before filtering is pressed into the Listctrl: Listctrl.setitemdata (0, (DWORD) pTreeItemInfo1);
2, after the filtering reconstruction tree to get the tree node pressed into the Listctrl: Listctrl.setitemdata (1, (DWORD) PTreeItemInfo2);
3, in the acquisition of data pressed into the Listctrl, due to the re-achievement, the original unfiltered tree node has been destroy,ctreeiteminfo* Ptreeiteminfo = (ctreeiteminfo*) Listctrl.getitemdata (0);
Ptreeiteminfo is a wild pointer, so when using the above two functions, you must pay attention to the application of the space on the heap and must always exist, to prevent the production of wild pointers .
On SetItemData and GetItemData