这是SDK里的:TVM_DELETEITEM Message--------------------------------------------------------------------------------Removes an item and all its children from a tree-view control. You can send this message explicitly or by using the TreeView_DeleteItem macro. Syntax To send this message, call the SendMessage function as follows. lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) TVM_DELETEITEM, // message ID (WPARAM) wParam, // = 0; not used, must be zero (LPARAM) lParam // = (LPARAM) (HTREEITEM) hitem; ); ParameterswParam Must be zero. hitem HTREEITEM handle to the item to delete. If hitem is set to TVI_ROOT or to NULL, all items are deleted. You can also use the TreeView_DeleteAllItems macro to delete all items. Return ValueReturns TRUE if successful, or FALSE otherwise.ResOnce an item is deleted, its handle is invalid and cannot be used.The parent window receives a TVN_DELETEITEM notification message when each item is removed. If the item label is being edited, the edit operation is canceled and the parent window receives the TVN_ENDLABELEDIT notification message. Message InformationHeader commctrl.h Minimum operating systems Windows NT 3.51, Windows 95 至于这个TVITEM怎么来的,既可以是Select的,也可以是你自己以前保留的,当然也可以是遍历来的了 如果要删除全部的Item,直接用TreeView_DeleteAllItems宏就可以了
HTREEITEM是在加入节点时的返回值
if(hSelItem)
DeleteItem(hSelItem);以上就是删除所选择的节点的方法罗!!!
To send this message, call the SendMessage function as follows.
lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) TVM_DELETEITEM, // message ID (WPARAM) wParam, // = 0; not used, must be zero (LPARAM) lParam // = (LPARAM) (HTREEITEM) hitem; );
ParameterswParam
Must be zero.
hitem
HTREEITEM handle to the item to delete. If hitem is set to TVI_ROOT or to NULL, all items are deleted. You can also use the TreeView_DeleteAllItems macro to delete all items.
Return ValueReturns TRUE if successful, or FALSE otherwise.ResOnce an item is deleted, its handle is invalid and cannot be used.The parent window receives a TVN_DELETEITEM notification message when each item is removed. If the item label is being edited, the edit operation is canceled and the parent window receives the TVN_ENDLABELEDIT notification message. Message InformationHeader commctrl.h
Minimum operating systems Windows NT 3.51, Windows 95
至于这个TVITEM怎么来的,既可以是Select的,也可以是你自己以前保留的,当然也可以是遍历来的了
如果要删除全部的Item,直接用TreeView_DeleteAllItems宏就可以了