Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

CaretIndex

Defines the current item (caret location).

C

int WINAPI SftTree_GetCaretIndex(HWND hwndCtl);
int WINAPI SftTree_SetCaretIndex(HWND hwndCtl, int index);
int WINAPI SftTreeSplit_GetCaretIndex(HWND hwndCtl);
int WINAPI SftTreeSplit_SetCaretIndex(HWND hwndCtl, int index);

C++

int CSftTree::GetCaretIndex() const;
int CSftTree::SetCaretIndex(int index);
int CSftTreeSplit::GetCaretIndex() const;
int CSftTreeSplit::SetCaretIndex(int index);

Parameters

hwndCtl

The window handle of the tree control.

index

The zero-based index of the item which will become the current item.

Returns

GetCaretIndex returns the zero-based index of the item that has the focus rectangle.

SetCaretIndex returns 0 if the function was successful, otherwise -1.

Comments

The GetCaretIndex and SetCaretIndex functions define the current item (caret location).

GetCaretIndex retrieves the index of the item that has the focus rectangle. The item may or may not also be selected. The display of the focus rectangle can be controlled using SetShowFocus.

SetCaretIndex automatically makes the current item visible, its parents are expanded if necessary and the item is displayed in the tree window area. The item is not automatically selected.

Examples

C

        /* Make row header width optimal, so text and pictures are */
        /* not clipped horizontally.                               */
        SftTree_MakeRowHeaderOptimal(g_hwndTree);/* Make row header width optimal */

        SftTree_MakeColumnOptimal(g_hwndTree, 0);/* Only make the first column optimal */
        SftTree_RecalcHorizontalExtent(g_hwndTree);/* Update horizontal scroll bar */

        SftTree_SetCaretIndex(g_hwndTree, 0);
        SftTree_SetCurSel(g_hwndTree, 0);
        CopyPictureFromCurrentItem(g_hwndTree);

        // Set a timer so we can update our progress bars every once in a while
        SetTimer(hwnd, TIMERID, 333, NULL);
        return 0;
     }
    case WM_DESTROY:

C++

    /* Make row header width optimal, so text and pictures are  */
    /* not clipped horizontally.                               */
    m_Tree.MakeRowHeaderOptimal(0, FALSE);/* Make row header width optimal */

    m_Tree.MakeColumnOptimal(0);/* Only make the first column optimal */
    m_Tree.RecalcHorizontalExtent(0, FALSE);/* Update horizontal scroll bar */

    m_Tree.SetCaretIndex(0);
    m_Tree.SetCurSel(0);
    CopyPictureFromCurrentItem();

    // Set a timer so we can update our progress bars every once in a while
    SetTimer(TIMERID, 333, NULL);

    return 0;
}

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