COMCTL32.DLL Functions

This section details the functions available in the Common Control Library (COMCTL32.DLL), which provides a rich set of user interface controls and functionality for Windows applications.

ListView_Create

HWND ListView_Create(HINSTANCE hInstance, const RECT* prc, HWND hwndParent, UINT_PTR id, DWORD dwStyle);

Description

Creates a new list-view control. This function is a macro that uses the CreateWindowEx function with the WC_LISTVIEW window class.

Parameters

Name Type Description
hInstance HINSTANCE Handle to the application instance.
prc const RECT* Pointer to a RECT structure that specifies the initial size and position of the list-view control.
hwndParent HWND Handle to the parent window.
id UINT_PTR The identifier of the list-view control.
dwStyle DWORD The style of the list-view control. For a list of possible styles, see List-View Control Styles.

Return Value

Returns the handle to the new list-view control if successful, or NULL otherwise.

Remarks

The ListView_Create macro is the preferred way to create a list-view control. It simplifies the process by handling the necessary window class registration and creation parameters.

ListView_AddItem

INT ListView_AddItem(HWND hwnd, const LVITEM* pitem);

Description

Adds a new item to a list-view control. This macro sends the LVM_INSERTITEM message.

Parameters

Name Type Description
hwnd HWND Handle to the list-view control.
pitem const LVITEM* Pointer to an LVITEM structure that specifies the properties of the item to be added. The iItem member of this structure should be set to the index where the item should be inserted, or -1 to insert at the end.

Return Value

Returns the index of the new item if successful, or -1 if an error occurs.

TreeView_Create

HWND TreeView_Create(HINSTANCE hInstance, const RECT* prc, HWND hwndParent, UINT_PTR id, DWORD dwStyle);

Description

Creates a new tree-view control. This function is a macro that uses the CreateWindowEx function with the WC_TREEVIEW window class.

Parameters

Name Type Description
hInstance HINSTANCE Handle to the application instance.
prc const RECT* Pointer to a RECT structure that specifies the initial size and position of the tree-view control.
hwndParent HWND Handle to the parent window.
id UINT_PTR The identifier of the tree-view control.
dwStyle DWORD The style of the tree-view control. For a list of possible styles, see Tree-View Control Styles.

Return Value

Returns the handle to the new tree-view control if successful, or NULL otherwise.

Remarks

The TreeView_Create macro is the preferred way to create a tree-view control.

TreeView_InsertItem

HTREEITEM TreeView_InsertItem(HWND hwnd, const TVINSERTSTRUCT* ptvis);

Description

Inserts a new item into a tree-view control. This macro sends the TVM_INSERTITEM message.

Parameters

Name Type Description
hwnd HWND Handle to the tree-view control.
ptvis const TVINSERTSTRUCT* Pointer to a TVINSERTSTRUCT structure that contains the properties of the new item.

Return Value

Returns the handle to the newly inserted item if successful, or NULL otherwise.