//------------------------------------------------------------------------ //! Changes the row sorting in regard to the specified column //! //! @param nCol The index of the column //! @param bAscending Should the arrow be up or down //! @return True / false depending on whether sort is possible //------------------------------------------------------------------------ bool CGridListCtrlGroups::SortColumn(int nCol, bool bAscending) { CWaitCursor waitCursor; if (IsGroupViewEnabled()) { SetRedraw(FALSE); GroupByColumn(nCol); // Cannot use GetGroupInfo during sort PARAMSORT paramsort(m_hWnd, nCol, bAscending, GetColumnTrait(nCol)); for(int nRow=0 ; nRow < GetItemCount() ; ++nRow) { int nGroupId = GetRowGroupId(nRow); if (nGroupId!=-1 && paramsort.m_GroupNames.FindKey(nGroupId)==-1) paramsort.m_GroupNames.Add(nGroupId, GetGroupHeader(nGroupId)); } SetRedraw(TRUE); Invalidate(FALSE); // Avoid bug in CListCtrl::SortGroups() which differs from ListView_SortGroups if (!ListView_SortGroups(m_hWnd, SortFuncGroup, ¶msort)) return false; } else { if (!CGridListCtrlEx::SortColumn(nCol, bAscending)) return false; } return true; }
bool CListCtrl_SortItems::SortColumn(int columnIndex, bool ascending) { PARAMSORT paramsort(this, columnIndex, ascending); if (IsNumColumn(columnIndex)) SortItemsEx(NumSortFunc, (DWORD_PTR)¶msort); else SortItemsEx(SortFunc, (DWORD_PTR)¶msort); return true; }