credui: Add a banner and message box to the dialog presented by CredUIPromptForCredentials.

This commit is contained in:
Rob Shearman 2007-10-25 19:17:45 +01:00 committed by Alexandre Julliard
parent cecc7ab747
commit ce5b6c8410
11 changed files with 158 additions and 81 deletions

View File

@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = credui.dll
IMPORTLIB = libcredui.$(IMPLIBEXT)
IMPORTS = user32 kernel32
IMPORTS = comctl32 user32 kernel32
C_SRCS = \
credui_main.c

BIN
dlls/credui/banner.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -24,6 +24,9 @@
#include "winnls.h"
#include "credui_resources.h"
/* @makedep: banner.bmp */
IDB_BANNER BITMAP LOADONCALL DISCARDABLE banner.bmp
#include "credui_De.rc"
#include "credui_En.rc"
#include "credui_Ko.rc"

View File

@ -20,17 +20,21 @@
LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 220, 82
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149
STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Benutzername und Passwort eingeben"
CAPTION "IDS_TITLEFORMAT"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "&Benutzername:",IDC_STATIC,7,10,72,12,SS_CENTERIMAGE
EDITTEXT IDC_USERNAME,80,10,130,12,ES_AUTOHSCROLL
LTEXT "&Passwort:",IDC_STATIC,7,27,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,27,130,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "&Domänenname:",IDC_STATIC,7,44,72,12,SS_CENTERIMAGE
EDITTEXT IDC_DOMAIN,80,44,130,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,7,61,50,14
PUSHBUTTON "Abbrechen",IDCANCEL,67,61,50,14
CONTROL IDB_BANNER,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,0,
0,213,37
LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP
LTEXT "&Benutzername:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE
CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN |
CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12
LTEXT "&Passwort:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "&Remember my password",IDC_SAVE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12
DEFPUSHBUTTON "OK",IDOK,97,128,50,14
PUSHBUTTON "Abbrechen",IDCANCEL,156,128,50,14
END

View File

@ -20,17 +20,27 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 220, 82
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149
STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Enter User Name and Password"
CAPTION "IDS_TITLEFORMAT"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "&User Name:",IDC_STATIC,7,10,72,12,SS_CENTERIMAGE
EDITTEXT IDC_USERNAME,80,10,130,12,ES_AUTOHSCROLL
LTEXT "&Password:",IDC_STATIC,7,27,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,27,130,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "&Domain Name:",IDC_STATIC,7,44,72,12,SS_CENTERIMAGE
EDITTEXT IDC_DOMAIN,80,44,130,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,7,61,50,14
PUSHBUTTON "Cancel",IDCANCEL,67,61,50,14
CONTROL IDB_BANNER,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,0,
0,213,37
LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP
LTEXT "&User name:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE
CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN |
CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12
LTEXT "&Password:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "&Remember my password",IDC_SAVE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12
DEFPUSHBUTTON "OK",IDOK,97,128,50,14
PUSHBUTTON "Cancel",IDCANCEL,156,128,50,14
END
STRINGTABLE DISCARDABLE
{
IDS_TITLEFORMAT "Connect to %s"
IDS_MESSAGEFORMAT "Connecting to %s"
}

View File

@ -21,17 +21,21 @@
LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 220, 82
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149
STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "사용자 이름과 암호 입력"
CAPTION "IDS_TITLEFORMAT"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "사용자 이름(&U):",IDC_STATIC,7,10,72,12,SS_CENTERIMAGE
EDITTEXT IDC_USERNAME,80,10,130,12,ES_AUTOHSCROLL
LTEXT "암호(&P):",IDC_STATIC,7,27,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,27,130,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "도메인 이름(&D):",IDC_STATIC,7,44,72,12,SS_CENTERIMAGE
EDITTEXT IDC_DOMAIN,80,44,130,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "확인",IDOK,7,61,50,14
PUSHBUTTON "취소",IDCANCEL,67,61,50,14
CONTROL IDB_BANNER,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,0,
0,213,37
LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP
LTEXT "사용자 이름(&U):",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE
CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN |
CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12
LTEXT "암호(&P):",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "&Remember my password",IDC_SAVE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12
DEFPUSHBUTTON "확인",IDOK,97,128,50,14
PUSHBUTTON "취소",IDCANCEL,156,128,50,14
END

View File

@ -20,17 +20,21 @@
LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 220, 82
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149
STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Skriv inn brukernavn og passord"
CAPTION "IDS_TITLEFORMAT"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Br&ukernavn:",IDC_STATIC,7,10,72,12,SS_CENTERIMAGE
EDITTEXT IDC_USERNAME,80,10,130,12,ES_AUTOHSCROLL
LTEXT "&Passord:",IDC_STATIC,7,27,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,27,130,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "&Domene:",IDC_STATIC,7,44,72,12,SS_CENTERIMAGE
EDITTEXT IDC_DOMAIN,80,44,130,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,7,61,50,14
PUSHBUTTON "Avbryt",IDCANCEL,67,61,50,14
CONTROL IDB_BANNER,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,0,
0,213,37
LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP
LTEXT "Br&ukernavn:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE
CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN |
CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12
LTEXT "&Passord:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "&Remember my password",IDC_SAVE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12
DEFPUSHBUTTON "OK",IDOK,97,128,50,14
PUSHBUTTON "Avbryt",IDCANCEL,156,128,50,14
END

View File

@ -21,17 +21,21 @@
LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 220, 82
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149
STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Enter User Name and Password"
CAPTION "IDS_TITLEFORMAT"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "&U¿ytkownik:",IDC_STATIC,7,10,72,12,SS_CENTERIMAGE
EDITTEXT IDC_USERNAME,80,10,130,12,ES_AUTOHSCROLL
LTEXT "&Has³o:",IDC_STATIC,7,27,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,27,130,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "&Domena:",IDC_STATIC,7,44,72,12,SS_CENTERIMAGE
EDITTEXT IDC_DOMAIN,80,44,130,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "&OK",IDOK,7,61,50,14
PUSHBUTTON "&Anuluj",IDCANCEL,67,61,50,14
CONTROL IDB_BANNER,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,0,
0,213,37
LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP
LTEXT "&U¿ytkownik:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE
CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN |
CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12
LTEXT "&Has³o:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "&Remember my password",IDC_SAVE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12
DEFPUSHBUTTON "&OK",IDOK,97,128,50,14
PUSHBUTTON "&Anuluj",IDCANCEL,156,128,50,14
END

View File

@ -20,17 +20,21 @@
LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 220, 82
IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149
STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Ange användarnamn och lösenord"
CAPTION "IDS_TITLEFORMAT"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "A&nvändarnamn:",IDC_STATIC,7,10,72,12,SS_CENTERIMAGE
EDITTEXT IDC_USERNAME,80,10,130,12,ES_AUTOHSCROLL
LTEXT "&Lösenord:",IDC_STATIC,7,27,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,27,130,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "&Domännamn:",IDC_STATIC,7,44,72,12,SS_CENTERIMAGE
EDITTEXT IDC_DOMAIN,80,44,130,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,7,61,50,14
PUSHBUTTON "Avbryt",IDCANCEL,67,61,50,14
CONTROL IDB_BANNER,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,0,
0,213,37
LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP
LTEXT "A&nvändarnamn:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE
CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN |
CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12
LTEXT "&Lösenord:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE
EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "&Remember my password",IDC_SAVE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12
DEFPUSHBUTTON "OK",IDOK,97,128,50,14
PUSHBUTTON "Avbryt",IDCANCEL,156,128,50,14
END

View File

@ -25,6 +25,7 @@
#include "winnt.h"
#include "winuser.h"
#include "wincred.h"
#include "commctrl.h"
#include "credui_resources.h"
@ -66,6 +67,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
DisableThreadLibraryCalls(hinstDLL);
hinstCredUI = hinstDLL;
InitCommonControls();
}
else if (fdwReason == DLL_PROCESS_DETACH)
{
@ -102,6 +104,7 @@ struct cred_dialog_params
PWSTR pszPassword;
ULONG ulPasswordMaxChars;
BOOL fSave;
DWORD dwFlags;
};
static INT_PTR CALLBACK CredDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
@ -112,26 +115,42 @@ static INT_PTR CALLBACK CredDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
case WM_INITDIALOG:
{
struct cred_dialog_params *params = (struct cred_dialog_params *)lParam;
DWORD ret;
WCHAR user[256];
WCHAR domain[256];
SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)params);
ret = CredUIParseUserNameW(params->pszUsername, user, 256, domain, 256);
if (ret == ERROR_SUCCESS)
if (params->pszMessageText)
SetDlgItemTextW(hwndDlg, IDC_MESSAGE, params->pszMessageText);
else
{
SetDlgItemTextW(hwndDlg, IDC_USERNAME, user);
SetDlgItemTextW(hwndDlg, IDC_DOMAIN, domain);
WCHAR format[256];
WCHAR message[256];
LoadStringW(hinstCredUI, IDS_MESSAGEFORMAT, format, sizeof(format)/sizeof(format[0]));
snprintfW(message, sizeof(message)/sizeof(message[0]), format, params->pszTargetName);
SetDlgItemTextW(hwndDlg, IDC_MESSAGE, message);
}
SetDlgItemTextW(hwndDlg, IDC_USERNAME, params->pszUsername);
SetDlgItemTextW(hwndDlg, IDC_PASSWORD, params->pszPassword);
if (ret == ERROR_SUCCESS && user[0])
if (params->pszUsername[0])
SetFocus(GetDlgItem(hwndDlg, IDC_PASSWORD));
else
SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
if (params->pszCaptionText)
SetWindowTextW(hwndDlg, params->pszCaptionText);
else
{
WCHAR format[256];
WCHAR title[256];
LoadStringW(hinstCredUI, IDS_TITLEFORMAT, format, sizeof(format)/sizeof(format[0]));
snprintfW(title, sizeof(title)/sizeof(title[0]), format, params->pszTargetName);
SetWindowTextW(hwndDlg, title);
}
if (params->dwFlags & (CREDUI_FLAGS_DO_NOT_PERSIST|CREDUI_FLAGS_PERSIST))
ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE);
else if (params->fSave)
CheckDlgButton(hwndDlg, IDC_SAVE, BST_CHECKED);
return FALSE;
}
case WM_COMMAND:
@ -139,22 +158,40 @@ static INT_PTR CALLBACK CredDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
{
case MAKELONG(IDOK, BN_CLICKED):
{
ULONG domainlen;
struct cred_dialog_params *params =
(struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME);
LPWSTR user;
INT len;
INT len2;
domainlen = GetDlgItemTextW(hwndDlg, IDC_DOMAIN,
params->pszUsername,
params->ulUsernameMaxChars);
if (domainlen && (domainlen < params->ulUsernameMaxChars))
len = GetWindowTextLengthW(hwndUsername);
user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
GetWindowTextW(hwndUsername, user, len + 1);
if (!user[0])
return TRUE;
if (!strchrW(user, '\\') && !strchrW(user, '@'))
{
params->pszUsername[domainlen++] = '\\';
params->pszUsername[domainlen] = '\0';
INT len_target = strlenW(params->pszTargetName);
memcpy(params->pszUsername, params->pszTargetName,
min(len_target, params->ulUsernameMaxChars) * sizeof(WCHAR));
if (len_target + 1 < params->ulUsernameMaxChars)
params->pszUsername[len_target] = '\\';
if (len_target + 2 < params->ulUsernameMaxChars)
params->pszUsername[len_target + 1] = '\0';
}
if (domainlen < params->ulUsernameMaxChars)
GetDlgItemTextW(hwndDlg, IDC_USERNAME,
params->pszUsername + domainlen,
params->ulUsernameMaxChars - domainlen);
else if (params->ulUsernameMaxChars > 0)
params->pszUsername[0] = '\0';
len2 = strlenW(params->pszUsername);
memcpy(params->pszUsername + len2, user, min(len, params->ulUsernameMaxChars - len2) * sizeof(WCHAR));
if (params->ulUsernameMaxChars)
params->pszUsername[len2 + min(len, params->ulUsernameMaxChars - len2 - 1)] = '\0';
HeapFree(GetProcessHeap(), 0, user);
GetDlgItemTextW(hwndDlg, IDC_PASSWORD, params->pszPassword,
params->ulPasswordMaxChars);
@ -219,6 +256,7 @@ DWORD WINAPI CredUIPromptForCredentialsW(PCREDUI_INFOW pUIInfo,
params.pszPassword = pszPassword;
params.ulPasswordMaxChars = ulPasswordMaxChars;
params.fSave = pfSave ? *pfSave : FALSE;
params.dwFlags = dwFlags;
ret = DialogBoxParamW(hinstCredUI, MAKEINTRESOURCEW(IDD_CREDDIALOG),
pUIInfo ? pUIInfo->hwndParent : NULL,

View File

@ -19,5 +19,11 @@
#define IDD_CREDDIALOG 100
#define IDC_USERNAME 101
#define IDC_PASSWORD 102
#define IDC_DOMAIN 103
#define IDC_MESSAGE 103
#define IDC_STATIC 104
#define IDC_SAVE 105
#define IDB_BANNER 200
#define IDS_TITLEFORMAT 300
#define IDS_MESSAGEFORMAT 301