Nikolay Sivov : user32: Fix Edit margins calculation for empty client area case.
Alexandre Julliard
julliard at winehq.org
Mon Apr 7 13:20:06 CDT 2014
Module: wine
Branch: master
Commit: ba3a6d1f4b9db64c12301d0d83d559dd6f1e83b4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ba3a6d1f4b9db64c12301d0d83d559dd6f1e83b4
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri Apr 4 21:45:28 2014 +0400
user32: Fix Edit margins calculation for empty client area case.
---
dlls/user32/edit.c | 2 +-
dlls/user32/tests/edit.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index ac4cec3..e9cbc91 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -2914,7 +2914,7 @@ static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
default_right_margin = tm.tmAveCharWidth / 2;
min_size = calc_min_set_margin_size(dc, default_left_margin, default_right_margin);
GetClientRect(es->hwndSelf, &rc);
- if(rc.right - rc.left < min_size) {
+ if (!IsRectEmpty(&rc) && (rc.right - rc.left < min_size)) {
default_left_margin = es->left_margin;
default_right_margin = es->right_margin;
}
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index e95964c..d5fd3b2 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -1423,6 +1423,8 @@ static void test_margins(void)
RECT old_rect, new_rect;
INT old_right_margin;
DWORD old_margins, new_margins;
+ LOGFONTA lf;
+ HFONT hfont;
hwEdit = create_editcontrol(WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
@@ -1470,6 +1472,46 @@ static void test_margins(void)
ok(new_rect.bottom == old_rect.bottom, "The bottom border of the rectangle has changed\n");
DestroyWindow (hwEdit);
+
+ memset(&lf, 0, sizeof(lf));
+ lf.lfHeight = -11;
+ lf.lfWeight = FW_NORMAL;
+ lf.lfCharSet = DEFAULT_CHARSET;
+ strcpy(lf.lfFaceName, "Tahoma");
+
+ hfont = CreateFontIndirectA(&lf);
+ ok(hfont != NULL, "got %p\n", hfont);
+
+ /* Empty window rectangle */
+ hwEdit = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);
+ ok(hwEdit != NULL, "got %p\n", hwEdit);
+ GetClientRect(hwEdit, &old_rect);
+ ok(IsRectEmpty(&old_rect), "got rect %d,%d-%d,%d\n", old_rect.left, old_rect.top, old_rect.right, old_rect.bottom);
+
+ old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
+ ok(old_margins == 0, "got %x\n", old_margins);
+
+ SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
+ old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
+ ok(HIWORD(old_margins) > 0 && LOWORD(old_margins) > 0, "got %d, %d\n", HIWORD(old_margins), LOWORD(old_margins));
+
+ DestroyWindow(hwEdit);
+
+ /* Size is not enough to display a text, but not empty */
+ hwEdit = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 2, 2, NULL, NULL, NULL, NULL);
+ ok(hwEdit != NULL, "got %p\n", hwEdit);
+ GetClientRect(hwEdit, &old_rect);
+ ok(!IsRectEmpty(&old_rect), "got rect %d,%d-%d,%d\n", old_rect.left, old_rect.top, old_rect.right, old_rect.bottom);
+
+ old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
+ ok(old_margins == 0, "got %x\n", old_margins);
+
+ SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
+ old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
+ ok(old_margins == 0, "got %d, %d\n", HIWORD(old_margins), LOWORD(old_margins));
+
+ DeleteObject(hfont);
+ DestroyWindow(hwEdit);
}
static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
More information about the wine-cvs
mailing list