Windows: Correctly display the password edit "black dot" instead of a '*' when showing it then hiding it.

This commit is contained in:
Mounir IDRASSI 2015-08-27 02:01:19 +02:00
parent 8c0fadc068
commit cfb591a9e9
5 changed files with 47 additions and 54 deletions

View File

@ -88,6 +88,8 @@ HFONT hUserUnderlineBoldFont = NULL;
HFONT WindowTitleBarFont;
WCHAR EditPasswordChar = 0;
int ScreenDPI = USER_DEFAULT_SCREEN_DPI;
double DPIScaleFactorX = 1;
double DPIScaleFactorY = 1;
@ -873,7 +875,7 @@ static LRESULT CALLBACK BootPwdFieldProc (HWND hwnd, UINT message, WPARAM wParam
return 1;
}
return CallWindowProc (wp, hwnd, message, wParam, lParam);
return CallWindowProcW (wp, hwnd, message, wParam, lParam);
}
@ -884,8 +886,8 @@ void ToBootPwdField (HWND hwndDlg, UINT ctrlId)
{
HWND hwndCtrl = GetDlgItem (hwndDlg, ctrlId);
SetWindowLongPtr (hwndCtrl, GWLP_USERDATA, (LONG_PTR) GetWindowLongPtr (hwndCtrl, GWLP_WNDPROC));
SetWindowLongPtr (hwndCtrl, GWLP_WNDPROC, (LONG_PTR) BootPwdFieldProc);
SetWindowLongPtrW (hwndCtrl, GWLP_USERDATA, (LONG_PTR) GetWindowLongPtrW (hwndCtrl, GWLP_WNDPROC));
SetWindowLongPtrW (hwndCtrl, GWLP_WNDPROC, (LONG_PTR) BootPwdFieldProc);
}
@ -10851,3 +10853,25 @@ void SetPim (HWND hwndDlg, UINT ctrlId, int pim)
SetDlgItemText (hwndDlg, ctrlId, "");
}
void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id)
{
if ((EditPasswordChar == 0) && GetCheckBox (hwndDlg, checkBoxId))
{
EditPasswordChar = (WCHAR) SendMessageW (GetDlgItem (hwndDlg, edit1Id), EM_GETPASSWORDCHAR, 0, 0);
}
SendMessageW (GetDlgItem (hwndDlg, edit1Id),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, checkBoxId) ? 0 : EditPasswordChar,
0);
InvalidateRect (GetDlgItem (hwndDlg, edit1Id), NULL, TRUE);
if (edit2Id)
{
SendMessageW (GetDlgItem (hwndDlg, edit2Id),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, checkBoxId) ? 0 : EditPasswordChar,
0);
InvalidateRect (GetDlgItem (hwndDlg, edit2Id), NULL, TRUE);
}
}

View File

@ -491,6 +491,7 @@ BOOL LaunchWindowsIsoBurner (HWND hwnd, const char *isoPath);
BOOL IsApplicationInstalled (const char *appName);
int GetPim (HWND hwndDlg, UINT ctrlId);
void SetPim (HWND hwndDlg, UINT ctrlId, int pim);
void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id);
#ifdef __cplusplus
}

View File

@ -534,10 +534,13 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
return 1;
}
SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
if (GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD))
{
// simulate hiding password
SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD), EM_SETPASSWORDCHAR, '*', 0);
InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, 0);
}
SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE), FALSE);
@ -614,11 +617,7 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (lw == IDC_SHOW_PASSWORD)
{
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD) ? 0 : '*',
0);
InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, 0);
return 1;
}

View File

@ -5409,16 +5409,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (lw == IDC_SHOW_PASSWORD && nCurPageNo == PASSWORD_PAGE)
{
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD) ? 0 : '*',
0);
SendMessage (GetDlgItem (hwndDlg, IDC_VERIFY),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD) ? 0 : '*',
0);
InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
InvalidateRect (GetDlgItem (hwndDlg, IDC_VERIFY), NULL, TRUE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_VERIFY);
return 1;
}
@ -5509,11 +5500,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (lw == IDC_SHOW_PASSWORD_SINGLE)
{
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_SINGLE) ? 0 : '*',
0);
InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT), NULL, TRUE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_SINGLE, IDC_PASSWORD_DIRECT, 0);
return 1;
}
}

View File

@ -2314,26 +2314,13 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (lw == IDC_SHOW_PASSWORD_CHPWD_ORI)
{
SendMessage (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_ORI) ? 0 : '*',
0);
InvalidateRect (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD), NULL, TRUE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_ORI, IDC_OLD_PASSWORD, 0);
return 1;
}
if (lw == IDC_SHOW_PASSWORD_CHPWD_NEW)
{
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW) ? 0 : '*',
0);
SendMessage (GetDlgItem (hwndDlg, IDC_VERIFY),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW) ? 0 : '*',
0);
InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
InvalidateRect (GetDlgItem (hwndDlg, IDC_VERIFY), NULL, TRUE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW, IDC_PASSWORD, IDC_VERIFY);
return 1;
}
@ -2660,10 +2647,13 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
return 1;
}
SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
if (GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD))
{
// simulate hiding password
SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD), EM_SETPASSWORDCHAR, '*', 0);
InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, 0);
}
SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE), FALSE);
@ -2745,11 +2735,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (lw == IDC_SHOW_PASSWORD)
{
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD) ? 0 : '*',
0);
InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, 0);
return 1;
}
@ -3274,11 +3260,7 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
if (lw == IDC_SHOW_PASSWORD_MO)
{
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL),
EM_SETPASSWORDCHAR,
GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_MO) ? 0 : '*',
0);
InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), NULL, TRUE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_MO, IDC_PASSWORD_PROT_HIDVOL, 0);
return 1;
}