cryptui: Add an add purpose dialog.

This commit is contained in:
Juan Lang 2008-12-18 14:04:30 -08:00 committed by Alexandre Julliard
parent 3c7e95ee39
commit 356596561c
3 changed files with 73 additions and 0 deletions

View File

@ -170,3 +170,14 @@ BEGIN
24,100,220,90
PUSHBUTTON "Add &Purpose...", IDC_ADD_PURPOSE,184,194,60,14
END
IDD_ADD_CERT_PURPOSE DIALOG DISCARDABLE 0,0,200,68
CAPTION "Add Purpose"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Add the object identifier (OID) for the certificate purpose you wish to add:",
stc1, 6,6,190,28
EDITTEXT IDC_NEW_PURPOSE, 6,28,190,14, ES_AUTOVSCROLL|ES_MULTILINE|WS_TABSTOP|WS_VSCROLL
PUSHBUTTON "OK", IDOK, 33,48,60,14
PUSHBUTTON "Cancel", IDCANCEL, 100,48,60,14
END

View File

@ -89,6 +89,7 @@
#define IDD_HIERARCHY 102
#define IDD_USERNOTICE 103
#define IDD_CERT_PROPERTIES_GENERAL 104
#define IDD_ADD_CERT_PURPOSE 105
#define IDB_SMALL_ICONS 200
#define IDB_CERT 201
@ -126,4 +127,6 @@
#define IDC_CERTIFICATE_USAGES 2405
#define IDC_ADD_PURPOSE 2406
#define IDC_NEW_PURPOSE 2500
#endif /* ndef __CRYPTUIRES_H_ */

View File

@ -1593,6 +1593,59 @@ static void add_purpose(HWND hwnd, LPCSTR oid)
}
}
#define MAX_PURPOSE 255
static LRESULT CALLBACK add_purpose_dlg_proc(HWND hwnd, UINT msg,
WPARAM wp, LPARAM lp)
{
LRESULT ret = 0;
char buf[MAX_PURPOSE + 1];
switch (msg)
{
case WM_INITDIALOG:
SendMessageW(GetDlgItem(hwnd, IDC_NEW_PURPOSE), EM_SETLIMITTEXT,
MAX_PURPOSE, 0);
ShowScrollBar(GetDlgItem(hwnd, IDC_NEW_PURPOSE), SB_VERT, FALSE);
SetWindowLongPtrW(hwnd, DWLP_USER, lp);
break;
case WM_COMMAND:
switch (HIWORD(wp))
{
case BN_CLICKED:
switch (LOWORD(wp))
{
case IDOK:
SendMessageA(GetDlgItem(hwnd, IDC_NEW_PURPOSE), WM_GETTEXT,
sizeof(buf) / sizeof(buf[0]), (LPARAM)buf);
if (!buf[0])
{
/* An empty purpose is the same as cancelling */
EndDialog(hwnd, IDCANCEL);
ret = TRUE;
}
else
{
HWND parent = (HWND)GetWindowLongPtrW(hwnd, DWLP_USER);
FIXME("validate %s\n", debugstr_a(buf));
add_purpose(parent, buf);
EndDialog(hwnd, wp);
ret = TRUE;
}
break;
case IDCANCEL:
EndDialog(hwnd, wp);
ret = TRUE;
break;
}
break;
}
break;
}
return ret;
}
static WCHAR *get_cert_property_as_string(PCCERT_CONTEXT cert, DWORD prop)
{
WCHAR *name = NULL;
@ -1862,6 +1915,12 @@ static LRESULT CALLBACK cert_properties_general_dlg_proc(HWND hwnd, UINT msg,
case BN_CLICKED:
switch (LOWORD(wp))
{
case IDC_ADD_PURPOSE:
if (DialogBoxParamW(hInstance,
MAKEINTRESOURCEW(IDD_ADD_CERT_PURPOSE), hwnd,
add_purpose_dlg_proc, (LPARAM)hwnd) == IDOK)
SendMessageW(GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
break;
case IDC_ENABLE_ALL_PURPOSES:
case IDC_DISABLE_ALL_PURPOSES:
case IDC_ENABLE_SELECTED_PURPOSES: