From cc044603e52d6447a767af9bb1b8433c053fa9dc Mon Sep 17 00:00:00 2001 From: Haoyang Chen Date: Tue, 12 Mar 2024 10:29:56 +0800 Subject: [PATCH 1/2] user32/tests: Add EM_{SET,GET}PASSWORDCHAR tests for edit control. --- dlls/user32/tests/edit.c | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index 9316cff7d85..285ced457bf 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -3474,6 +3474,59 @@ static void test_format_rect(void) } } +static void test_PASSWORDCHAR(void) +{ + HWND hwEdit; + LONG r; + CHAR passwdChar = '#'; + + hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + + r = SendMessageA(hwEdit, EM_SETPASSWORDCHAR, passwdChar, 0); + todo_wine ok(r == 1, "Expected: 1, got: %ld\n", r); + + r = get_edit_style(hwEdit); + ok(r & ES_PASSWORD, "Wrong style expected ES_PASSWORD got: 0x%lx\n", r); + + r = SendMessageA(hwEdit, EM_GETPASSWORDCHAR, 0, 0); + ok(r == passwdChar, "Expected: 0, got: %ld\n", r); + + DestroyWindow (hwEdit); + + hwEdit = create_editcontrol(ES_MULTILINE, 0); + r = get_edit_style(hwEdit); + ok(r == ES_MULTILINE, "Wrong style expected ES_PASSWORD got: 0x%lx\n", r); + + r = SendMessageA(hwEdit, EM_SETPASSWORDCHAR, passwdChar, 0); + todo_wine ok(r == 1, "Expected: 1, got: %ld\n", r); + + r = get_edit_style(hwEdit); + ok(r == (ES_MULTILINE | ES_PASSWORD), "Wrong style expected ES_MULTILINE|ES_PASSWORD got: 0x%lx\n", r); + + if (winetest_interactive) + SetWindowTextA(hwEdit, "TEST"); + + r = SendMessageA(hwEdit, EM_GETPASSWORDCHAR, 0, 0); + ok(r == passwdChar, "Expected: 0, got: %ld\n", r); + + if (winetest_interactive) + { + RedrawWindow(hwEdit, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); + Sleep(2000); + } + + r = SendMessageA(hwEdit, EM_SETPASSWORDCHAR, 0, 0); + todo_wine ok(r == 1, "Expected: 1, got: %ld\n", r); + + r = get_edit_style(hwEdit); + ok(r == ES_MULTILINE, "Wrong style expected ES_PASSWORD got: 0x%lx\n", r); + + r = SendMessageA(hwEdit, EM_GETPASSWORDCHAR, 0, 0); + ok(r == 0, "Expected: 0, got: %ld\n", r); + + DestroyWindow (hwEdit); +} + START_TEST(edit) { BOOL b; @@ -3513,6 +3566,7 @@ START_TEST(edit) test_wordbreak_proc(); test_dbcs_WM_CHAR(); test_format_rect(); + test_PASSWORDCHAR(); UnregisterWindowClasses(); } From 288e04e825c1053e31ae2bf5fe9b27d835119c1b Mon Sep 17 00:00:00 2001 From: Haoyang Chen Date: Tue, 12 Mar 2024 10:36:32 +0800 Subject: [PATCH 2/2] user32/edit: Make a show or set password char in the multiline edit control. --- dlls/user32/edit.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index 9607cecc223..53638deae5a 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -387,10 +387,15 @@ static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData_linedef(EDITSTATE *es, HD tabdef.pTabStops = es->tabs; tabdef.iTabOrigin = 0; - hr = ScriptStringAnalyse(udc, &es->text[index], line_def->net_length, - (1.5*line_def->net_length+16), -1, - SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_TAB, -1, - NULL, NULL, NULL, &tabdef, NULL, &line_def->ssa); + if (es->style & ES_PASSWORD) + hr = ScriptStringAnalyse(udc, &es->password_char, line_def->net_length, + (1.5*line_def->net_length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_TAB|SSA_PASSWORD, + -1, NULL, NULL, NULL, &tabdef, NULL, &line_def->ssa); + else + hr = ScriptStringAnalyse(udc, &es->text[index], line_def->net_length, + (1.5*line_def->net_length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_TAB, + -1, NULL, NULL, NULL, &tabdef, NULL, &line_def->ssa); + if (FAILED(hr)) { WARN("ScriptStringAnalyse failed (%lx)\n",hr); @@ -2964,9 +2969,6 @@ static void EDIT_EM_SetPasswordChar(EDITSTATE *es, WCHAR c) { LONG style; - if (es->style & ES_MULTILINE) - return; - if (es->password_char == c) return;