cryptui: Allow toggling a usage in the certificate manager dialog's advanced dialog.

This commit is contained in:
Juan Lang 2009-01-07 16:32:00 -08:00 committed by Alexandre Julliard
parent 06505e53ae
commit a180f505b9

View File

@ -337,6 +337,28 @@ static void add_known_usages_to_list(HWND lv, CheckBitmapIndex state)
} }
} }
static void toggle_usage(HWND hwnd, int iItem)
{
LVITEMW item;
int res;
HWND lv = GetDlgItem(hwnd, IDC_CERTIFICATE_USAGES);
item.mask = LVIF_STATE;
item.iItem = iItem;
item.iSubItem = 0;
item.stateMask = LVIS_STATEIMAGEMASK;
res = SendMessageW(lv, LVM_GETITEMW, 0, (LPARAM)&item);
if (res)
{
int state = item.state >> 12;
item.state = INDEXTOSTATEIMAGEMASK(
state == CheckBitmapIndexChecked ? CheckBitmapIndexUnchecked :
CheckBitmapIndexChecked);
SendMessageW(lv, LVM_SETITEMSTATE, iItem, (LPARAM)&item);
}
}
static LRESULT CALLBACK cert_mgr_advanced_dlg_proc(HWND hwnd, UINT msg, static LRESULT CALLBACK cert_mgr_advanced_dlg_proc(HWND hwnd, UINT msg,
WPARAM wp, LPARAM lp) WPARAM wp, LPARAM lp)
{ {
@ -369,6 +391,21 @@ static LRESULT CALLBACK cert_mgr_advanced_dlg_proc(HWND hwnd, UINT msg,
add_known_usages_to_list(lv, CheckBitmapIndexChecked); add_known_usages_to_list(lv, CheckBitmapIndexChecked);
break; break;
} }
case WM_NOTIFY:
{
NMHDR *hdr = (NMHDR *)lp;
NMITEMACTIVATE *nm;
switch (hdr->code)
{
case NM_CLICK:
nm = (NMITEMACTIVATE *)lp;
toggle_usage(hwnd, nm->iItem);
SendMessageW(GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
break;
}
break;
}
case WM_COMMAND: case WM_COMMAND:
switch (wp) switch (wp)
{ {
@ -2685,28 +2722,6 @@ static void set_general_cert_properties(HWND hwnd, struct edit_cert_data *data)
show_cert_usages(hwnd, data); show_cert_usages(hwnd, data);
} }
static void toggle_usage(HWND hwnd, int iItem)
{
LVITEMW item;
int res;
HWND lv = GetDlgItem(hwnd, IDC_CERTIFICATE_USAGES);
item.mask = LVIF_STATE;
item.iItem = iItem;
item.iSubItem = 0;
item.stateMask = LVIS_STATEIMAGEMASK;
res = SendMessageW(lv, LVM_GETITEMW, 0, (LPARAM)&item);
if (res)
{
int state = item.state >> 12;
item.state = INDEXTOSTATEIMAGEMASK(
state == CheckBitmapIndexChecked ? CheckBitmapIndexUnchecked :
CheckBitmapIndexChecked);
SendMessageW(lv, LVM_SETITEMSTATE, iItem, (LPARAM)&item);
}
}
static void set_cert_string_property(PCCERT_CONTEXT cert, DWORD prop, static void set_cert_string_property(PCCERT_CONTEXT cert, DWORD prop,
LPWSTR str) LPWSTR str)
{ {