简体   繁体   中英

Can't remove treeview item in c++

I'm adding item in a treeview like that:

TVINSERTSTRUCT tvinsert;
tvinsert.hParent = selectedtreeitem;
tvinsert.hInsertAfter = TVI_LAST;
tvinsert.item.pszText = name;
tvinsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvinsert.item.iImage = 0;
tvinsert.item.iSelectedImage = 1;

HTREEITEM ti=(HTREEITEM)SendDlgItemMessage(_hSelf, IDC_TREE1, TVM_INSERTITEM, 0, (LPARAM)&tvinsert);

It works perfectly, but when I try to remove like that:

TreeView_DeleteItem(_hSelf, tvinsert);

It doesn't do anything.

It works with that:

SendDlgItemMessage(_hSelf, IDC_TREE1, TVM_DELETEITEM, TVGN_CARET, (LPARAM)tvinsert);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM