Author: hbelusca
Date: Thu Jul 13 00:21:32 2017
New Revision: 75325
URL:
http://svn.reactos.org/svn/reactos?rev=75325&view=rev
Log:
[SHELL32]: Enable showing the sorting arrows in the sorting header column of shell folder
listviews.
CORE-11776 #resolve
Modified:
trunk/reactos/dll/win32/shell32/CDefView.cpp
Modified: trunk/reactos/dll/win32/shell32/CDefView.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CDefView…
==============================================================================
--- trunk/reactos/dll/win32/shell32/CDefView.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/CDefView.cpp [iso-8859-1] Thu Jul 13 00:21:32 2017
@@ -103,10 +103,11 @@
BOOL m_isEditing;
CLSID m_Category;
- BOOL m_Destroyed;
+ BOOL m_Destroyed;
+
private:
-
HRESULT _MergeToolbar();
+ BOOL _Sort();
public:
CDefView();
@@ -688,6 +689,40 @@
return nDiff;
}
+BOOL CDefView::_Sort()
+{
+ HWND hHeader;
+ HDITEM hColumn;
+
+ if ((m_ListView.GetWindowLongPtr(GWL_STYLE) & ~LVS_NOSORTHEADER) == 0)
+ return TRUE;
+
+ hHeader = (HWND)m_ListView.SendMessage(LVM_GETHEADER, 0, 0);
+ ZeroMemory(&hColumn, sizeof(hColumn));
+
+ /* If the sorting column changed, remove the sorting style from the old column */
+ if ( (m_sortInfo.nLastHeaderID != -1) &&
+ (m_sortInfo.nLastHeaderID != m_sortInfo.nHeaderID) )
+ {
+ hColumn.mask = HDI_FORMAT;
+ Header_GetItem(hHeader, m_sortInfo.nLastHeaderID, &hColumn);
+ hColumn.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN);
+ Header_SetItem(hHeader, m_sortInfo.nLastHeaderID, &hColumn);
+ }
+
+ /* Set the sorting style to the new column */
+ hColumn.mask = HDI_FORMAT;
+ Header_GetItem(hHeader, m_sortInfo.nHeaderID, &hColumn);
+
+ hColumn.fmt &= (m_sortInfo.bIsAscending ? ~HDF_SORTDOWN : ~HDF_SORTUP );
+ hColumn.fmt |= (m_sortInfo.bIsAscending ? HDF_SORTUP : HDF_SORTDOWN);
+ Header_SetItem(hHeader, m_sortInfo.nHeaderID, &hColumn);
+
+ /* Sort the list, using the current values of nHeaderID and bIsAscending */
+ m_sortInfo.nLastHeaderID = m_sortInfo.nHeaderID;
+ return m_ListView.SortItems(ListViewCompareItems, this);
+}
+
PCUITEMID_CHILD CDefView::_PidlByItem(int i)
{
return reinterpret_cast<PCUITEMID_CHILD>(m_ListView.GetItemData(i));
@@ -906,8 +941,7 @@
FIXME("no m_pSF2Parent\n");
}
m_sortInfo.bIsAscending = TRUE;
- m_sortInfo.nLastHeaderID = m_sortInfo.nHeaderID;
- m_ListView.SortItems(ListViewCompareItems, this);
+ _Sort();
/*turn the listview's redrawing back on and force it to draw*/
m_ListView.SetRedraw(TRUE);
@@ -1525,15 +1559,14 @@
CheckToolbar();
break;
- /* the menu-ID's for sorting are 0x30... see shrec.rc */
+ /* the menu-ID's for sorting are 0x30... see shrec.rc */
case 0x30:
case 0x31:
case 0x32:
case 0x33:
m_sortInfo.nHeaderID = dwCmdID - 0x30;
m_sortInfo.bIsAscending = TRUE;
- m_sortInfo.nLastHeaderID = m_sortInfo.nHeaderID;
- m_ListView.SortItems(ListViewCompareItems, this);
+ _Sort();
break;
case FCIDM_SHVIEW_SNAPTOGRID:
@@ -1669,9 +1702,7 @@
m_sortInfo.bIsAscending = !m_sortInfo.bIsAscending;
else
m_sortInfo.bIsAscending = TRUE;
- m_sortInfo.nLastHeaderID = m_sortInfo.nHeaderID;
-
- m_ListView.SortItems(ListViewCompareItems, this);
+ _Sort();
break;
case LVN_GETDISPINFOA: