TreeView_DeleteAllItems macro (commctrl.h)

Deletes all items from a tree-view control.

Syntax

void TreeView_DeleteAllItems(
   hwnd
);

Parameters

hwnd

Type: HWND

Handle to the tree-view control.

Return value

None

Remarks

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);
TreeView_DeleteAllItems(hwnd);
SetWindowLong(hwnd, GWL_STYLE, styles);

Requirements

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