TreeView_DeleteAllItems macro (commctrl.h)

Deletes all items from a tree-view control.


void TreeView_DeleteAllItems(



Type: HWND

Handle to the tree-view control.

Return value



Once an item is deleted from a tree-view control, its HTREEITEM handle is invalid and cannot be used.

The parent window receives a TVN_DELETEITEM notification code 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 code.

You can also delete all items with the TreeView_DeleteItem macro or the TVM_DELETEITEM message by setting lParam to TVI_ROOT.

If the window style for a tree-view control contains TVS_NOSCROLL and all items are deleted, new items are not displayed until the window styles are reset. The following code shows one way to ensure that items are always displayed.

DWORD styles = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, styles);


Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header commctrl.h