[SHELL32]: Enable showing the sorting arrows in the sorting header column of shell folder listviews.

CORE-11776 #resolve

svn path=/trunk/; revision=75325
This commit is contained in:
Hermès Bélusca-Maïto 2017-07-13 00:21:32 +00:00
parent 6f2c13e4df
commit be9a0afc1f

View file

@ -103,10 +103,11 @@ class CDefView :
BOOL m_isEditing; BOOL m_isEditing;
CLSID m_Category; CLSID m_Category;
BOOL m_Destroyed; BOOL m_Destroyed;
private:
private:
HRESULT _MergeToolbar(); HRESULT _MergeToolbar();
BOOL _Sort();
public: public:
CDefView(); CDefView();
@ -688,6 +689,40 @@ INT CALLBACK CDefView::ListViewCompareItems(LPARAM lParam1, LPARAM lParam2, LPAR
return nDiff; 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) PCUITEMID_CHILD CDefView::_PidlByItem(int i)
{ {
return reinterpret_cast<PCUITEMID_CHILD>(m_ListView.GetItemData(i)); return reinterpret_cast<PCUITEMID_CHILD>(m_ListView.GetItemData(i));
@ -906,8 +941,7 @@ HRESULT CDefView::FillList()
FIXME("no m_pSF2Parent\n"); FIXME("no m_pSF2Parent\n");
} }
m_sortInfo.bIsAscending = TRUE; m_sortInfo.bIsAscending = TRUE;
m_sortInfo.nLastHeaderID = m_sortInfo.nHeaderID; _Sort();
m_ListView.SortItems(ListViewCompareItems, this);
/*turn the listview's redrawing back on and force it to draw*/ /*turn the listview's redrawing back on and force it to draw*/
m_ListView.SetRedraw(TRUE); m_ListView.SetRedraw(TRUE);
@ -1525,15 +1559,14 @@ LRESULT CDefView::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHand
CheckToolbar(); CheckToolbar();
break; 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 0x30:
case 0x31: case 0x31:
case 0x32: case 0x32:
case 0x33: case 0x33:
m_sortInfo.nHeaderID = dwCmdID - 0x30; m_sortInfo.nHeaderID = dwCmdID - 0x30;
m_sortInfo.bIsAscending = TRUE; m_sortInfo.bIsAscending = TRUE;
m_sortInfo.nLastHeaderID = m_sortInfo.nHeaderID; _Sort();
m_ListView.SortItems(ListViewCompareItems, this);
break; break;
case FCIDM_SHVIEW_SNAPTOGRID: case FCIDM_SHVIEW_SNAPTOGRID:
@ -1669,9 +1702,7 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl
m_sortInfo.bIsAscending = !m_sortInfo.bIsAscending; m_sortInfo.bIsAscending = !m_sortInfo.bIsAscending;
else else
m_sortInfo.bIsAscending = TRUE; m_sortInfo.bIsAscending = TRUE;
m_sortInfo.nLastHeaderID = m_sortInfo.nHeaderID; _Sort();
m_ListView.SortItems(ListViewCompareItems, this);
break; break;
case LVN_GETDISPINFOA: case LVN_GETDISPINFOA: