Handle state change message when repsonse is not required

Currently we show a messagebox with OK/CANCEL when response is
not required but that cannot handle state change messages.
Instead, show the "GenericPass" dialog with input disabled.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/443/head
Selva Nair 2021-08-14 09:32:36 -04:00
parent 131c75e560
commit e6e65a4883
1 changed files with 12 additions and 15 deletions

View File

@ -660,19 +660,6 @@ GenericPassDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
SetDlgItemTextW(hwndDlg, ID_TXT_DESCRIPTION, wstr); SetDlgItemTextW(hwndDlg, ID_TXT_DESCRIPTION, wstr);
/* If response is not required show a message box with the challenge
* text and autosubmit an empty password (see management-notes.txt)
*/
if ((param->flags & FLAG_CR_RESPONSE) == 0)
{
wchar_t title[256];
GetWindowTextW(hwndDlg, title, _countof(title));
if (MessageBoxExW(NULL, wstr, title, MB_OKCANCEL|MB_SETFOREGROUND|MB_TOPMOST, GetGUILanguage()) == IDOK)
SimulateButtonPress(hwndDlg, IDOK);
else
SimulateButtonPress(hwndDlg, IDCANCEL);
}
/* Set password echo on if needed */ /* Set password echo on if needed */
if (param->flags & FLAG_CR_ECHO) if (param->flags & FLAG_CR_ECHO)
SendMessage(GetDlgItem(hwndDlg, ID_EDT_RESPONSE), EM_SETPASSWORDCHAR, 0, 0); SendMessage(GetDlgItem(hwndDlg, ID_EDT_RESPONSE), EM_SETPASSWORDCHAR, 0, 0);
@ -695,8 +682,18 @@ GenericPassDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
else else
SetForegroundWindow(hwndDlg); SetForegroundWindow(hwndDlg);
/* disable OK button by default - not disabled in resources */ /* If response is not required hide the response field */
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); if ((param->flags & FLAG_CR_TYPE_CRV1 || param->flags & FLAG_CR_TYPE_CRTEXT)
&& !(param->flags & FLAG_CR_RESPONSE))
{
ShowWindow(GetDlgItem(hwndDlg, ID_LTEXT_RESPONSE), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, ID_EDT_RESPONSE), SW_HIDE);
}
else
{
/* disable OK button until response is filled-in */
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
}
break; break;