Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

InsertString

Inserts a new item using a string.

C

int SftTree_InsertString(HWND hwndCtl, int index, LPCTSTR lpszText);
int WINAPI SftTree_InsertString_A(HWND hwndCtl, int index, LPCSTR lpszText);
int WINAPI SftTree_InsertString_W(HWND hwndCtl, int index, LPCWSTR lpszText);
int SftTreeSplit_InsertString(HWND hwndCtl, int index, LPCTSTR lpszText);
int WINAPI SftTreeSplit_InsertString_A(HWND hwndCtl, int index, LPCSTR lpszText);
int WINAPI SftTreeSplit_InsertString_W(HWND hwndCtl, int index, LPCWSTR lpszText);

C++

int CSftTree::InsertString(int index, LPCTSTR lpszText);
int CSftTreeSplit::InsertString(int index, LPCTSTR lpszText);

Parameters

hwndCtl

The window handle of the tree control.

index

The zero-based index of the location where the item is to be inserted. If -1 is specified, the item will be added at the end of the tree control.

lpszText

Points to the null-terminated string that is to be used as text for the first (or only) column. This parameter may be NULL.

Returns

The return value is the zero-based index of the newly added item. The return value is -1 if an error occurred.

Comments

The InsertString function inserts a new item using a string.

By default, new items are added at level 0. Use SetItemLevel to change an item's level.

The tree control creates a copy of the string supplied.

AddString can be used to add items at the end of the list.

The maximum number of items is the maximum positive number which can be represented by the "int" type. However, virtual storage will be depleted well before this theoretical limit can be reached, not to mention the excessive load-time.

The WM_SETREDRAW Windows message (CWnd::SetRedraw) can be used to suppress the tree control from being redrawn when many items are added. The use of WM_SETREDRAW is strongly recommended when adding many items to the tree control, as it avoids significant processing while items are added and drastically reduces the time needed to populate the tree control. WM_SETREDRAW (FALSE) should be used once, then all items should be added followed by one final WM_SETREDRAW (TRUE) message.

See Also C/C++ API | Categories | Notifications