diff --git a/dlls/user/edit.c b/dlls/user/edit.c index 47f317d8c18..bc67e4323a9 100644 --- a/dlls/user/edit.c +++ b/dlls/user/edit.c @@ -4061,7 +4061,7 @@ static LRESULT EDIT_WM_Create(EDITSTATE *es, LPCWSTR name) EDIT_SetRectNP(es, &clientRect); if (name && *name) { - EDIT_EM_ReplaceSel(es, FALSE, name, FALSE, TRUE); + EDIT_EM_ReplaceSel(es, FALSE, name, FALSE, FALSE); /* if we insert text to the editline, the text scrolls out * of the window, as the caret is placed after the insert * pos normally; thus we reset es->selection... to 0 and diff --git a/dlls/user/tests/edit.c b/dlls/user/tests/edit.c index 846ed2d2c88..0bd521be1cf 100644 --- a/dlls/user/tests/edit.c +++ b/dlls/user/tests/edit.c @@ -671,6 +671,40 @@ static void test_edit_control_4(void) DestroyWindow(hwEdit); } +/* Test if creating edit control without ES_AUTOHSCROLL and ES_AUTOVSCROLL + * truncates text that doesn't fit. + */ +static void test_edit_control_5(void) +{ + static const char *str = "test\r\ntest"; + HWND hWnd; + int len; + + hWnd = CreateWindowEx(0, + "EDIT", + str, + 0, + 10, 10, 1, 1, + NULL, NULL, NULL, NULL); + assert(hWnd); + + len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0); + ok(lstrlenA(str) == len, "text shouldn't have been truncated\n"); + DestroyWindow(hWnd); + + hWnd = CreateWindowEx(0, + "EDIT", + str, + ES_MULTILINE, + 10, 10, 1, 1, + NULL, NULL, NULL, NULL); + assert(hWnd); + + len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0); + ok(lstrlenA(str) == len, "text shouldn't have been truncated\n"); + DestroyWindow(hWnd); +} + static void test_margins(void) { HWND hwEdit; @@ -931,6 +965,7 @@ START_TEST(edit) test_edit_control_2(); test_edit_control_3(); test_edit_control_4(); + test_edit_control_5(); test_margins(); test_text_position();