Commit 3a7d3fcc authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

cryptui: Support sorting columns by clicking on their headers.

parent 9d62f475
...@@ -1062,6 +1062,49 @@ static void cert_mgr_do_export(HWND hwnd) ...@@ -1062,6 +1062,49 @@ static void cert_mgr_do_export(HWND hwnd)
} }
} }
static int CALLBACK cert_mgr_sort_by_text(HWND lv, int col, int index1,
int index2)
{
LVITEMW item;
WCHAR buf1[MAX_STRING_LEN];
WCHAR buf2[MAX_STRING_LEN];
item.cchTextMax = sizeof(buf1) / sizeof(buf1[0]);
item.mask = LVIF_TEXT;
item.pszText = buf1;
item.iItem = index1;
item.iSubItem = col;
SendMessageW(lv, LVM_GETITEMW, 0, (LPARAM)&item);
item.pszText = buf2;
item.iItem = index2;
SendMessageW(lv, LVM_GETITEMW, 0, (LPARAM)&item);
return strcmpW(buf1, buf2);
}
static int CALLBACK cert_mgr_sort_by_subject(LPARAM lp1, LPARAM lp2, LPARAM lp)
{
return cert_mgr_sort_by_text((HWND)lp, 0, lp1, lp2);
}
static int CALLBACK cert_mgr_sort_by_issuer(LPARAM lp1, LPARAM lp2, LPARAM lp)
{
return cert_mgr_sort_by_text((HWND)lp, 1, lp1, lp2);
}
static int CALLBACK cert_mgr_sort_by_date(LPARAM lp1, LPARAM lp2, LPARAM lp)
{
PCCERT_CONTEXT cert1 = (PCCERT_CONTEXT)lp1;
PCCERT_CONTEXT cert2 = (PCCERT_CONTEXT)lp2;
return CompareFileTime(&cert1->pCertInfo->NotAfter,
&cert2->pCertInfo->NotAfter);
}
static int CALLBACK cert_mgr_sort_by_friendly_name(LPARAM lp1, LPARAM lp2,
LPARAM lp)
{
return cert_mgr_sort_by_text((HWND)lp, 3, lp1, lp2);
}
static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp,
LPARAM lp) LPARAM lp)
{ {
...@@ -1141,6 +1184,35 @@ static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, ...@@ -1141,6 +1184,35 @@ static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp,
cert_mgr_do_remove(hwnd); cert_mgr_do_remove(hwnd);
break; break;
} }
case LVN_COLUMNCLICK:
{
NMLISTVIEW *nmlv = (NMLISTVIEW *)lp;
HWND lv = GetDlgItem(hwnd, IDC_MGR_CERTS);
/* FIXME: doesn't support swapping sort order between ascending
* and descending.
*/
switch (nmlv->iSubItem)
{
case 0:
SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv,
(LPARAM)cert_mgr_sort_by_subject);
break;
case 1:
SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv,
(LPARAM)cert_mgr_sort_by_issuer);
break;
case 2:
SendMessageW(lv, LVM_SORTITEMS, 0,
(LPARAM)cert_mgr_sort_by_date);
break;
case 3:
SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv,
(LPARAM)cert_mgr_sort_by_friendly_name);
break;
}
break;
}
} }
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment