Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

AddString

Adds a new item to a tree control. The new item is added as the last item at level 0.

C

int SftTree_AddString(HWND hwndCtl, LPCTSTR lpszText);
int WINAPI SftTree_AddString_A(HWND hwndCtl, LPCSTR lpszText);
int WINAPI SftTree_AddString_W(HWND hwndCtl, LPCWSTR lpszText);
int SftTreeSplit_AddString(HWND hwndCtl, LPCTSTR lpszText);
int WINAPI SftTreeSplit_AddString_A(HWND hwndCtl, LPCSTR lpszText);
int WINAPI SftTreeSplit_AddString_W(HWND hwndCtl, LPCWSTR lpszText);

C++

int CSftTree::AddString(LPCTSTR lpszText);
int CSftTreeSplit::AddString(LPCTSTR lpszText);

Parameters

hwndCtl

The window handle of the tree control.

lpszText

A null-terminated string that is to be used as text for the cell of the first (or only) column.

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 AddString function adds a new item to a tree control. The new item is added as the last item at level 0.

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.

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.

InsertString can be used to insert items at a specific position.

Items can be deleted using DeleteString.

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.

In a tree control using a virtual data source, this function cannot be used and an error is returned.

Examples

C

        /*------------------------------------------------------------------------------*/
        /* Add a few items.                                                             */
        /*------------------------------------------------------------------------------*/

        {
            int index;

            index = SftTree_AddString(g_hwndTree, TEXT("Progress Bars"));
            SftTree_SetTextCol(g_hwndTree, index, 0, TEXT("SftTree/DLL supports progress bars as cell background (partial or full size)."));

            // add progress bar samples
            {
                SFTTREE_CELLINFOPARM CellInfo;

                int i = SftTree_AddString(g_hwndTree, TEXT("Progress Bar - Full Size"));
                SftTree_SetItemLevel(g_hwndTree, i, 1);

C++

    /*------------------------------------------------------------------------------*/
    /* Add a few items.                                                             */
    /*------------------------------------------------------------------------------*/

    {
        int index;

        index = m_Tree.AddString(_T("Progress Bars"));
        m_Tree.SetText(index, 0, _T("SftTree/DLL supports progress bars as cell background (partial or full size)."));

        // add progress bar samples
        {
            SFTTREE_CELLINFOPARM CellInfo;

            int i = m_Tree.AddString(_T("Progress Bar - Full Size"));
            m_Tree.SetItemLevel(i, 1);

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