TreeView_Expand macro (commctrl.h)

The TreeView_Expand macro expands or collapses the list of child items associated with the specified parent item, if any. You can use this macro or send the TVM_EXPAND message explicitly.

Syntax

BOOL TreeView_Expand(
   HWND      hwnd,
   HTREEITEM hitem,
   UINT      code
);

Parameters

hwnd

Type: HWND

Handle to a tree-view control.

hitem

Type: HTREEITEM

Handle to the parent item that will be expanded or collapsed.

code

Type: UINT

Action flag. For a list of possible values, see the description of the wParam parameter in TVM_EXPAND.

Return value

Type: BOOL

Returns nonzero if the operation was successful, or zero otherwise.

Remarks

Expanding a node that is already expanded, or collapsing a node that is already collapsed is considered a successful operation and the macro returns a nonzero value. Attempting to expand or collapse a node that has no children is considered a failure and the return value is zero.

When an item is first expanded by a TVM_EXPAND message, the action generates TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification codes and the item's TVIS_EXPANDEDONCE state flag is set. As long as this state flag remains set, subsequent TVM_EXPAND messages do not generate TVN_ITEMEXPANDING or TVN_ITEMEXPANDED notifications. To reset the TVIS_EXPANDEDONCE state flag, you must send a TVM_EXPAND message with the TVE_COLLAPSE and TVE_COLLAPSERESET flags set. Attempting to explicitly set TVIS_EXPANDEDONCE will result in unpredictable behavior.

The expand operation may fail if the owner of the treeview control denies the operation in response to a TVN_ITEMEXPANDING notification.

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