Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

Dependent

Returns dependent item information for a parent item.

C

int WINAPI SftTree_GetDependent(HWND hwndCtl, int index, int type);
int WINAPI SftTreeSplit_GetDependent(HWND hwndCtl, int index, int type);

C++

int CSftTree::GetDependent(int index, int type) const;
int CSftTreeSplit::GetDependent(int index, int type) const;

Parameters

hwndCtl

The window handle of the tree control.

index

The zero-based index of the parent item for which dependent item information is to be retrieved.

type

A value indicating the type of dependent item information to retrieve.

SFTTREE_DEPENDENT_FIRSTRetrieves the index of the first dependent.
SFTTREE_DEPENDENT_LASTRetrieves the index of the last dependent.

Returns

The return value is the index of the requested dependent item or -1 if the specified item doesn't have any dependents.

Comments

The GetDependent function returns dependent item information for a parent item.

The index returned is not necessarily an immediate dependent. The dependent retrieved may be at any level below the parent item level, not just at the next lower level.

Examples

C

    int parentIndex;

    // sort this item's dependents
    SftTree_SortColDependentsEx(hwndTree, index, 0, fAscending ? SortCallbackExAscending : SortCallbackExDescending);
    // now visit all dependents and sort each dependent's child items.
    if (index < 0)
        parentIndex = 0;
    else
        parentIndex = SftTree_GetDependent(hwndTree, index, SFTTREE_DEPENDENT_FIRST);// start with first item
    for ( ; parentIndex >= 0 ; parentIndex = SftTree_GetSibling(hwndTree, parentIndex, SFTTREE_SIBLING_NEXT)) {
        SortItems(hwndTree, parentIndex, fAscending);
    }
}

static void SetSortDirection(HWND hwndTree, BOOL fAscending)
{

C++

    int parentIndex;

    // sort this item's dependents
    m_Tree.SortDependents(index, 0, fAscending ? SortCallbackExAscending : SortCallbackExDescending);
    // now visit all dependents and sort each dependent's child items.
    if (index < 0)
        parentIndex = 0;
    else
        parentIndex = m_Tree.GetDependent(index, SFTTREE_DEPENDENT_FIRST);// start with first item
    for ( ; parentIndex >= 0 ; parentIndex = m_Tree.GetSibling(parentIndex, SFTTREE_SIBLING_NEXT)) {
        SortItems(parentIndex, fAscending);
    }
}

void CSampleView::SetSortDirection(BOOL fAscending)
{

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