From: Jacob Czekalla jczekalla@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56873 --- dlls/comctl32/edit.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c index 4b950412617..3d9def178bc 100644 --- a/dlls/comctl32/edit.c +++ b/dlls/comctl32/edit.c @@ -2232,6 +2232,26 @@ static void EDIT_AdjustFormatRect(EDITSTATE *es) EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP); }
+static int EDIT_is_valid_format_rect(EDITSTATE *es, const RECT *rc) +{ + RECT edit_rect; + int text_height = es->line_height * es->line_count; + + GetClientRect(es->hwndSelf, &edit_rect); + if (rc->bottom == 0 && rc->top == 0 && rc->right == 0 && rc->left == 0) + return 0; + if (rc->top >= rc->bottom) + return 0; + if (rc->left >= rc->right) + return 0; + if (text_height > (rc->bottom - rc->top)) + return 0; + if (es->text_width > (rc->right - rc->left)) + return 0; + if ((rc->bottom - rc->top) > (edit_rect.bottom - edit_rect.top)) + return 0; + return 1; +}
/********************************************************************* * @@ -2247,7 +2267,10 @@ static void EDIT_SetRectNP(EDITSTATE *es, const RECT *rc) INT bw, bh; ExStyle = GetWindowLongPtrW(es->hwndSelf, GWL_EXSTYLE);
- CopyRect(&es->format_rect, rc); + if (!EDIT_is_valid_format_rect(es, rc)) + GetClientRect(es->hwndSelf, &es->format_rect); + else + CopyRect(&es->format_rect, rc);
if (ExStyle & WS_EX_CLIENTEDGE) { es->format_rect.left++;