On SetItemData and GetItemData

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.