From: Jacob Czekalla <jczekalla(a)codeweavers.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56873 --- dlls/user32/edit.c | 38 ++++++++++++++++++++++++++++++-------- dlls/user32/tests/edit.c | 4 ++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index 39f429813d6..9adeefb1efa 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -2297,9 +2297,12 @@ static void EDIT_AdjustFormatRect(EDITSTATE *es) /* Windows doesn't care to fix text placement for SL controls */ es->format_rect.bottom = es->format_rect.top + es->line_height; - /* Always stay within the client area */ - GetClientRect(es->hwndSelf, &ClientRect); - es->format_rect.bottom = min(es->format_rect.bottom, ClientRect.bottom); + if (!(es->style & ES_MULTILINE)) + { + /* Always stay within the client area */ + GetClientRect(es->hwndSelf, &ClientRect); + es->format_rect.bottom = min(es->format_rect.bottom, ClientRect.bottom); + } if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) EDIT_BuildLineDefs_ML(es, 0, get_text_length(es), 0, NULL); @@ -2307,6 +2310,14 @@ static void EDIT_AdjustFormatRect(EDITSTATE *es) EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP); } +static int EDIT_is_valid_format_rect(const EDITSTATE *es, const RECT *rc) +{ + if (IsRectEmpty(rc)) + return 0; + if (es->text_width > (rc->right - rc->left) || (es->line_height * es->line_count) > (rc->bottom - rc->top)) + return 0; + return 1; +} /********************************************************************* * @@ -2319,12 +2330,23 @@ static void EDIT_AdjustFormatRect(EDITSTATE *es) static void EDIT_SetRectNP(EDITSTATE *es, const RECT *rc) { LONG_PTR ExStyle; - INT bw, bh; + INT bw, bh, too_large = 0; + RECT edit_rect; ExStyle = GetWindowLongPtrW(es->hwndSelf, GWL_EXSTYLE); - - CopyRect(&es->format_rect, rc); - - if (ExStyle & WS_EX_CLIENTEDGE) { + + if (EDIT_is_valid_format_rect(es, rc)) + { + CopyRect(&es->format_rect, rc); + GetClientRect(es->hwndSelf, &edit_rect); + if ((rc->bottom - rc->top) > (edit_rect.bottom - edit_rect.top)) + too_large = 1; + } + else + { + GetClientRect(es->hwndSelf, &es->format_rect); + } + + if (ExStyle & WS_EX_CLIENTEDGE && !too_large) { es->format_rect.left++; es->format_rect.right--; diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index d5e2207df91..a6ef469ca7f 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -3468,9 +3468,9 @@ static void test_format_rect(void) SendMessageA(edit, EM_GETRECT, 0, (LPARAM)&rect); if (tests[i].expected_equal) - todo_wine ok(EqualRect(&old_rect, &rect), "Expected format rectangle to be equal to client rectangle.\n"); + ok(EqualRect(&old_rect, &rect), "Expected format rectangle to be equal to client rectangle.\n"); else - todo_wine ok((rect.right - rect.left) > (old_rect.right - old_rect.left), "Expected format rect to be larger than client rectangle.\n"); + ok((rect.right - rect.left) > (old_rect.right - old_rect.left), "Expected format rect to be larger than client rectangle.\n"); DestroyWindow(edit); } } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6304