Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

SortDependents

Sorts items.

C

BOOL WINAPI SftTree_SortDependentsEx(HWND hwndCtl,
        int index,
        SFTTREE_SORTPROCEX lpfnCompareEx);
BOOL SftTree_SortColDependentsEx(HWND hwndCtl,
        int index,
        int realCol,
        SFTTREE_SORTPROCEX lpfnCompareEx);
BOOL WINAPI SftTree_SortDependentsCellData(HWND hwndCtl,
        int index,
        int realCol,
        SFTTREE_SORTPROC_CELLDATA lpfnCompareCellData);
BOOL WINAPI SftTree_SortDependentsItem(HWND hwndCtl,
        int index,
        int realCol,
        SFTTREE_SORTPROC_ITEM lpfnCompareItem);
BOOL WINAPI SftTreeSplit_SortDependentsEx(HWND hwndCtl,
        int index,
        SFTTREE_SORTPROCEX lpfnCompareEx);
BOOL SftTreeSplit_SortColDependentsEx(HWND hwndCtl,
        int index,
        int realCol,
        SFTTREE_SORTPROCEX lpfnCompareEx);
BOOL WINAPI SftTreeSplit_SortDependentsCellData(HWND hwndCtl,
        int index,
        int realCol,
        SFTTREE_SORTPROC_CELLDATA lpfnCompareCellData);
BOOL WINAPI SftTreeSplit_SortDependentsItem(HWND hwndCtl,
        int index,
        int realCol,
        SFTTREE_SORTPROC_ITEM lpfnCompareItem);

C++

BOOL CSftTree::SortDependents(int index, SFTTREE_SORTPROCEX lpfnCompareEx);
BOOL CSftTree::SortDependents(int index,
        int realCol,
        SFTTREE_SORTPROC_CELLDATA lpfnCompareCellData);
BOOL CSftTree::SortDependents(int index,
        int realCol,
        SFTTREE_SORTPROCEX lpfnCompareEx);
BOOL CSftTree::SortDependents(int index,
        int realCol,
        SFTTREE_SORTPROC_ITEM lpfnCompareItem);
BOOL CSftTreeSplit::SortDependents(int index, SFTTREE_SORTPROCEX lpfnCompareEx);
BOOL CSftTreeSplit::SortDependents(int index,
        int realCol,
        SFTTREE_SORTPROC_CELLDATA lpfnCompareCellData);
BOOL CSftTreeSplit::SortDependents(int index,
        int realCol,
        SFTTREE_SORTPROCEX lpfnCompareEx);
BOOL CSftTreeSplit::SortDependents(int index,
        int realCol,
        SFTTREE_SORTPROC_ITEM lpfnCompareItem);

Parameters

hwndCtl

The window handle of the tree control.

index

The zero-based index of the item whose immediate dependents will be sorted. This parameter can be -1, in which case all items at the root level (level 0) are sorted.

realCol

The zero-based column number whose text is to be sorted.

lpfnCompareEx

A pointer to a string comparison callback routine of type SFTTREE_SORTPROCEX. This parameter may be NULL, in which case items are sorted in ascending fashion.

lpfnCompareCellData

A pointer to a string comparison callback routine of type SFTTREE_SORTPROC_CELLDATA. This parameter may be NULL, in which case items are sorted in ascending fashion.

lpfnCompareItem

A pointer to a string comparison callback routine of type SFTTREE_SORTPROC_ITEM. This parameter may be NULL, in which case items are sorted in ascending fashion.

Returns

The return value is TRUE if the function was successful, otherwise FALSE is returned.

Comments

The SortDependents functions sort items.

The column text sorted is based on the column specified using realCol or last defined using SetAccessColumn. Functions, which do not allow the realCol parameter, access the column last defined by SetAccessColumn or the last column referenced by a column specific function. The last column accessed can be retrieved using GetAccessColumn.

When sorting dependents, only immediate dependents are sorted, i.e. items on the immediate lower level. Dependents of items being sorted are moved with their parent item, but are not sorted. Use a separate SortDependents call for each parent item to be sorted.

The sorting algorithm used preserves the order of an already sorted list, when many items have identical keys. This allows multiple columns to be sorted by sorting the least significant column first and the most significant column last.

If an application doesn't add tree items with a string component for the column being sorted, but uses the (obsolete) DrawInfoCallback drawing callback routine to supply strings when items are painted, this function can only be used to sort items by item data values.

In a tree control using a virtual data source, sorting functions cannot be used and an error is returned. The external virtual data source should be sorted instead.

Additional forms of the SortDependents functions exist, which use a SFTTREE_SORTPROC callback, but are only provided for compatibility with earlier versions of SftTree/DLL and are not documented.

Examples

C

    CellInfo.index = index;
    CellInfo.iCol = 0;
    SftTree_GetCellInfo(hwndTree, &CellInfo);
    if (TogglePicture(&CellInfo.Cell.CellPicture1))
        SftTree_SetCellInfo(hwndTree, &CellInfo);
}

/**********************************************************************/
/*                        Column Header Sorting                       */
/**********************************************************************/

static BOOL g_fAscending = TRUE;

static void ShowSortDirection(HWND hwndTree, BOOL fAscending)
{
    LPSFTTREE_COLUMN_EX lpCol;

C++

    CellInfo.index = index;
    CellInfo.iCol = 0;
    m_Tree.GetCellInfo(&CellInfo);
    if (TogglePicture(&CellInfo.Cell.CellPicture1))
        m_Tree.SetCellInfo(&CellInfo);
}

/**********************************************************************/
/*                        Column Header Sorting                       */
/**********************************************************************/

void CSampleView::ShowSortDirection(BOOL fAscending)
{
    LPSFTTREE_COLUMN_EX lpCol;
    int nCols;

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