Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

CurSel

Defines the index of the selected item (single selection tree control).

C

int WINAPI SftTree_GetCurSel(HWND hwndCtl);
int WINAPI SftTree_SetCurSel(HWND hwndCtl, int index);
int WINAPI SftTreeSplit_GetCurSel(HWND hwndCtl);
int WINAPI SftTreeSplit_SetCurSel(HWND hwndCtl, int index);

C++

int CSftTree::GetCurSel() const;
int CSftTree::SetCurSel(int index);
int CSftTreeSplit::GetCurSel() const;
int CSftTreeSplit::SetCurSel(int index);

Parameters

hwndCtl

The window handle of the tree control.

index

The zero-based index of the item to be selected. This parameter may be -1 to deselect the currently selected item.

Returns

GetCurSel returns the zero-based index of the currently selected item in a single selection tree control. If no item is selected or if the tree control has the multiple selection attribute, the value -1 is returned.

SetCurSel returns the value 0 if the function was successful, otherwise -1 is returned.

Comments

The GetCurSel and SetCurSel functions define the index of the selected item (single selection tree control).

GetCurSel and SetCurSel can only be used with single selection tree controls. GetSel and SetSel are used with multi-selection tree controls.

GetCaretIndex can be used to retrieve the current item, i.e. the item that has the focus rectangle.

Examples

C

static void CopyPictureFromCurrentItem(HWND hwndTree)
{
    SFTTREE_CELLINFOPARM CellInfo;
    LPSFTTREE_COLUMN_EX lpCol;
    int nCols;
    int w, h;

    int index = SftTree_GetCurSel(hwndTree);

    if (index < 0) return;

    // retrieve current cell picture
    CellInfo.version = 7;
    CellInfo.index = index;
    CellInfo.iCol = 0;
    SftTree_GetCellInfo(hwndTree, &CellInfo);

C++

void CSampleView::CopyPictureFromCurrentItem()
{
    SFTTREE_CELLINFOPARM CellInfo;
    LPSFTTREE_COLUMN_EX lpCol;
    int nCols;
    int w, h;

    int index = m_Tree.GetCurSel();

    if (index < 0) return;

    // retrieve current cell picture
    CellInfo.version = 7;         
    CellInfo.index = index;
    CellInfo.iCol = 0;
    m_Tree.GetCellInfo(&CellInfo);

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