Enables sort indicators in column headers.
C
BOOL WINAPI SftBox_EnableSortIndicators(HWND hwndCtl, BOOL fOn, BOOL fAuto);
C++
BOOL CSftBox::EnableSortIndicators(BOOL fOn, BOOL fAuto);
hwndCtl
The window handle of the combo box control.
fOn
Set to TRUE to enable sort indicators, otherwise set to FALSE.
fAuto
Set to TRUE to let the combo box control handle user interaction automatically for sort indicators, otherwise set to FALSE. If TRUE, the combo box control will automatically set and reset sort indicators for all columns as the user clicks a column header to change the sort order.
The return value is always TRUE.
The EnableSortIndicators function enables sort indicators in the column headers of the static portion and the dropdown portion.
A column's sort indicator is defined by the colFlag member of the SFTBOX_COLUMN structure (SFTBOX_COL_SORTED_ASC, SFTBOX_COL_SORTED_DESC), using SetColumns.
If automatic sort indicator handling is enabled using fAuto, the combo box control will set and reset sort indicators for all columns as the user clicks a column header displayed as a button (see SetHeaderStyle) with the left mouse button to change the sort order. A column that is clicked for the first time shows the ascending indicator and the indicators of all other columns are removed. Clicking the same column again reverses the direction. The sort indicators are changed in the portion whose column header was clicked. The combo box control will not automatically sort the data.
The SFTBOXN_LBUTTONDOWN_COLUMN notification can be used by the application to determine when a column header of the dropdown portion was clicked by the user. In response to this notification, GetColumns (which returns the column attributes of the dropdown portion) can be used to retrieve the new sort indicators and the application can sort accordingly, typically using SortItems.
In a combo box control using a virtual data source, sorting has to be accomplished by adjusting the sort order of the virtual data source.
InitColumn(&aCols[COL_NAME], COL_NAME, 100, TEXT("State"));
InitColumn(&aCols[COL_ABBR], COL_ABBR, 40, TEXT("Abbr."));
InitColumn(&aCols[COL_CAPITAL], COL_CAPITAL, 100, TEXT("Capital"));
SftBox_SetColumns(hwndBox, COL_COUNT, aCols);
SftBox_SetShowHeaderDropDown(hwndBox, TRUE);// Column titles in the dropdown, as buttons
SftBox_SetHeaderStyle(hwndBox, SFTBOX_COLSTYLE_BUTTONTEXT);
SftBox_EnableSortIndicators(hwndBox, TRUE, TRUE);// A clicked column title shows the sort direction
SftBox_SetShowGrid(hwndBox, TRUE);
SftBox_SetGridStyle(hwndBox, SFTBOX_GRID_VERT);
SftBox_SetDroppedHeight(hwndBox, 10); // Show up to 10 items
SftBox_SetDropDownOptimalWidth(hwndBox, TRUE);// The dropdown is as wide as its columns
SftBox_SetDisableNoScroll(hwndBox, TRUE); // Scroll bars always shown, needed for the sizing box
SftBox_SetShowResizer(hwndBox, TRUE); // The user can resize the dropdown
SftBox_SetDarkMode(hwndBox, SFTBOX_DARKMODE_AUTO);
InitColumn(&aCols[COL_NAME], COL_NAME, 100, _T("State"));
InitColumn(&aCols[COL_ABBR], COL_ABBR, 40, _T("Abbr."));
InitColumn(&aCols[COL_CAPITAL], COL_CAPITAL, 100, _T("Capital"));
box.SetColumns(COL_COUNT, aCols);
box.SetShowHeaderDropDown(TRUE); // Column titles in the dropdown, as buttons
box.SetHeaderStyle(SFTBOX_COLSTYLE_BUTTONTEXT);
box.EnableSortIndicators(TRUE, TRUE);// A clicked column title shows the sort direction
box.SetShowGrid(TRUE);
box.SetGridStyle(SFTBOX_GRID_VERT);
box.SetDroppedHeight(10); // Show up to 10 items
box.SetDropDownOptimalWidth(TRUE); // The dropdown is as wide as its columns
box.SetDisableNoScroll(TRUE); // Scroll bars always shown, needed for the sizing box
box.SetShowResizer(TRUE); // The user can resize the dropdown
box.SetDarkMode(SFTBOX_DARKMODE_AUTO);
See Also C/C++ API | Categories | Notifications