From 81931d1ac015ddfc6a1aec6c401e0876e337b490 Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Tue, 24 Jun 2025 15:46:48 +0200 Subject: [PATCH] [SHELL32] Use the folder column, not the list column during DefView sorting (#8162) IShellFolder::CompareIDs does not understand ListView columns, we must provide it with a column index it understands during sorting. CORE-20251 --- dll/win32/shell32/CDefView.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp index 4cae91a25ba..105ecb71958 100644 --- a/dll/win32/shell32/CDefView.cpp +++ b/dll/win32/shell32/CDefView.cpp @@ -65,6 +65,7 @@ struct LISTVIEW_SORT_INFO bool bColumnIsFolderColumn; UINT8 Reserved; // Unused INT ListColumn; + INT FolderColumn; // Only valid during a sorting operation enum { UNSPECIFIEDCOLUMN = -1 }; void Reset() @@ -1262,7 +1263,7 @@ INT CALLBACK CDefView::ListViewCompareItems(LPARAM lParam1, LPARAM lParam2, LPAR PCUIDLIST_RELATIVE pidl2 = reinterpret_cast(lParam2); CDefView *pThis = reinterpret_cast(lpData); - HRESULT hres = pThis->m_pSFParent->CompareIDs(pThis->m_sortInfo.ListColumn, pidl1, pidl2); + HRESULT hres = pThis->m_pSFParent->CompareIDs(pThis->m_sortInfo.FolderColumn, pidl1, pidl2); if (FAILED_UNEXPECTEDLY(hres)) return 0; @@ -1317,7 +1318,7 @@ BOOL CDefView::_Sort(int Col) hColumn.fmt |= (m_sortInfo.Direction > 0 ? HDF_SORTUP : HDF_SORTDOWN); Header_SetItem(hHeader, m_sortInfo.ListColumn, &hColumn); - /* Sort the list, using the current values of ListColumn and bIsAscending */ + m_sortInfo.FolderColumn = MapListColumnToFolderColumn(m_sortInfo.ListColumn); ASSERT(m_sortInfo.Direction == 1 || m_sortInfo.Direction == -1); return m_ListView.SortItems(ListViewCompareItems, this); }