mirror of
https://github.com/reactos/reactos.git
synced 2025-01-04 21:38:43 +00:00
[SHELL32] Fix item order in Folder Options (#415)
This commit is contained in:
parent
173b79095c
commit
1f4c636453
1 changed files with 41 additions and 10 deletions
|
@ -359,6 +359,9 @@ CreateTreeImageList(VOID)
|
|||
static ADVANCED_ENTRY *
|
||||
Advanced_GetItem(DWORD dwID)
|
||||
{
|
||||
if (dwID == DWORD(-1))
|
||||
return NULL;
|
||||
|
||||
for (INT i = 0; i < s_AdvancedCount; ++i)
|
||||
{
|
||||
ADVANCED_ENTRY *pEntry = &s_Advanced[i];
|
||||
|
@ -701,24 +704,52 @@ Advanced_Compare(const void *x, const void *y)
|
|||
{
|
||||
ADVANCED_ENTRY *pEntry1 = (ADVANCED_ENTRY *)x;
|
||||
ADVANCED_ENTRY *pEntry2 = (ADVANCED_ENTRY *)y;
|
||||
|
||||
DWORD dwParentID1 = pEntry1->dwParentID;
|
||||
DWORD dwParentID2 = pEntry2->dwParentID;
|
||||
while (dwParentID1 != dwParentID2)
|
||||
|
||||
if (dwParentID1 == dwParentID2)
|
||||
return lstrcmpi(pEntry1->szText, pEntry2->szText);
|
||||
|
||||
DWORD i, m, n;
|
||||
const UINT MAX_DEPTH = 32;
|
||||
ADVANCED_ENTRY *pArray1[MAX_DEPTH];
|
||||
ADVANCED_ENTRY *pArray2[MAX_DEPTH];
|
||||
|
||||
// Make ancestor lists
|
||||
for (i = m = n = 0; i < MAX_DEPTH; ++i)
|
||||
{
|
||||
ADVANCED_ENTRY *pParent1 = Advanced_GetItem(dwParentID1);
|
||||
ADVANCED_ENTRY *pParent2 = Advanced_GetItem(dwParentID2);
|
||||
if (!pParent1 && !pParent2)
|
||||
break;
|
||||
if (!pParent1 && pParent2)
|
||||
return -1;
|
||||
if (pParent1 && !pParent2)
|
||||
return 1;
|
||||
INT nCompare = lstrcmpi(pParent1->szText, pParent2->szText);
|
||||
if (nCompare)
|
||||
return nCompare;
|
||||
dwParentID1 = pParent1->dwParentID;
|
||||
dwParentID2 = pParent2->dwParentID;
|
||||
|
||||
if (pParent1)
|
||||
{
|
||||
pArray1[m++] = pParent1;
|
||||
dwParentID1 = pParent1->dwParentID;
|
||||
}
|
||||
if (pParent2)
|
||||
{
|
||||
pArray2[n++] = pParent2;
|
||||
dwParentID2 = pParent2->dwParentID;
|
||||
}
|
||||
}
|
||||
|
||||
UINT k = min(m, n);
|
||||
for (i = 0; i < k; ++i)
|
||||
{
|
||||
INT nCompare = lstrcmpi(pArray1[m - i - 1]->szText, pArray2[n - i - 1]->szText);
|
||||
if (nCompare < 0)
|
||||
return -1;
|
||||
if (nCompare > 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (m < n)
|
||||
return -1;
|
||||
if (m > n)
|
||||
return 1;
|
||||
return lstrcmpi(pEntry1->szText, pEntry2->szText);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue