credui: Enumerate saved credentials and use these to populate the combo box.

This commit is contained in:
Rob Shearman 2007-11-17 17:31:02 +00:00 committed by Alexandre Julliard
parent 96714cf52e
commit cdb6e9ed82
1 changed files with 42 additions and 4 deletions
dlls/credui

View File

@ -130,8 +130,44 @@ struct cred_dialog_params
DWORD dwFlags; DWORD dwFlags;
}; };
static void CredDialogFillUsernameCombo(HWND hwndUsername, struct cred_dialog_params *params)
{
DWORD count;
DWORD i;
PCREDENTIALW *credentials;
if (!CredEnumerateW(NULL, 0, &count, &credentials))
return;
for (i = 0; i < count; i++)
{
COMBOBOXEXITEMW comboitem;
if (params->dwFlags & CREDUI_FLAGS_GENERIC_CREDENTIALS)
{
if ((credentials[i]->Type != CRED_TYPE_GENERIC) || !credentials[i]->UserName)
continue;
}
else
{
if (credentials[i]->Type == CRED_TYPE_GENERIC)
continue;
}
comboitem.mask = CBEIF_TEXT;
comboitem.iItem = -1;
comboitem.pszText = credentials[i]->UserName;
SendMessageW(hwndUsername, CBEM_INSERTITEMW, 0, (LPARAM)&comboitem);
}
CredFree(credentials);
}
static BOOL CredDialogInit(HWND hwndDlg, struct cred_dialog_params *params) static BOOL CredDialogInit(HWND hwndDlg, struct cred_dialog_params *params)
{ {
HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME);
HWND hwndPassword = GetDlgItem(hwndDlg, IDC_PASSWORD);
SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)params); SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)params);
if (params->pszMessageText) if (params->pszMessageText)
SetDlgItemTextW(hwndDlg, IDC_MESSAGE, params->pszMessageText); SetDlgItemTextW(hwndDlg, IDC_MESSAGE, params->pszMessageText);
@ -143,13 +179,15 @@ static BOOL CredDialogInit(HWND hwndDlg, struct cred_dialog_params *params)
snprintfW(message, sizeof(message)/sizeof(message[0]), format, params->pszTargetName); snprintfW(message, sizeof(message)/sizeof(message[0]), format, params->pszTargetName);
SetDlgItemTextW(hwndDlg, IDC_MESSAGE, message); SetDlgItemTextW(hwndDlg, IDC_MESSAGE, message);
} }
SetDlgItemTextW(hwndDlg, IDC_USERNAME, params->pszUsername); SetWindowTextW(hwndUsername, params->pszUsername);
SetDlgItemTextW(hwndDlg, IDC_PASSWORD, params->pszPassword); SetWindowTextW(hwndPassword, params->pszPassword);
CredDialogFillUsernameCombo(hwndUsername, params);
if (params->pszUsername[0]) if (params->pszUsername[0])
SetFocus(GetDlgItem(hwndDlg, IDC_PASSWORD)); SetFocus(hwndPassword);
else else
SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME)); SetFocus(hwndUsername);
if (params->pszCaptionText) if (params->pszCaptionText)
SetWindowTextW(hwndDlg, params->pszCaptionText); SetWindowTextW(hwndDlg, params->pszCaptionText);