Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

SortColumn1

Returns information about the currently sorted column.

C

BOOL WINAPI SftTree_GetSortColumn1(HWND hwndCtl, int* realCol, int* sortStyle);
BOOL WINAPI SftTreeSplit_GetSortColumn1(HWND hwndCtl, int* realCol, int* sortStyle);

C++

void CSftTree::GetSortColumn1(int& realCol, int& sortStyle) const;
void CSftTreeSplit::GetSortColumn1(int& realCol, int& sortStyle) const;

Parameters

hwndCtl

The window handle of the tree control.

realCol

A pointer to a field (C) or a reference (C++) where the real column number of the currently sorted column is returned. The value -1 is returned if no column has a sort indicator.

sortStyle

A pointer to a field (C) or a reference (C++) where the sort style of the currently sorted column is returned.

ValueDescription
SFTTREE_SORT_ASCThe sort indicator is shown as "ascending sort".
SFTTREE_SORT_DESCThe sort indicator is shown as "descending sort".

Returns

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

Comments

The GetSortColumn1 function returns information about the currently sorted column.

Only one column can be sorted ascending or descending at a time using the built-in sort handling using EnableSortIndicators with fAuto set to TRUE.

The GetSortColumn1 function is typically used when the SFTTREEN_LBUTTONDBLCLK_COLUMN_HEADER notification is received to retrieve the currently sorted column and its sort order so the application can sort the items using a call to the SortDependents function.

The EnableSortIndicators function is used to enable sort indicators in column headers.

Examples

C

                        SftTree_RecalcHorizontalExtent(g_hwndTree);/* Update horizontal scroll bar */
                    }
                    break;
                  }
                case SFTTREEN_LBUTTONDOWN_COLUMN_HEADER:
                case SFTTREEN_LBUTTONDBLCLK_COLUMN_HEADER: {
                    /* The user clicked/double-clicked the header */
                    int sortCol, sortStyle;
                    if (SftTree_GetSortColumn1(g_hwndTree, &sortCol, &sortStyle)) {/* Retrieve the current sort column */
                        BOOL ascending = (sortStyle == SFTTREE_SORT_ASC);
                        SftTree_SortColDependentsEx(g_hwndTree, -1, sortCol,
                            ascending ? Tree_SortCallbackExAscending : Tree_SortCallbackExDescending);/* Sort level 0 items using the column and order specified */
                    }
                    break;
                  }
                case SFTTREEN_LBUTTONDOWN_COLUMN_HEADERDD:

C++

/* This sample code sorts the selected column (items on    */
/* level 0 ONLY) based on the current sort indicator which */
/* is automatically managed by the tree control.           */

void CSampleView::OnColumnHeaderClick()
{
    int sortCol, sortStyle;
    if (m_Tree.GetSortColumn1(sortCol, sortStyle)) {/* Retrieve the current sort column */
        BOOL ascending = (sortStyle == SFTTREE_SORT_ASC);
        m_Tree.SortDependents(-1, sortCol,
            ascending ? SortCallbackExAscending : SortCallbackExDescending);/* Sort level 0 items using the column and order specified */
    }
}

/* Colummn Dropdown/Filter was clicked */
void CSampleView::OnColumnHeaderDDClick()

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