Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48803 Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/comctl32/edit.c | 4 +-- dlls/comctl32/tests/edit.c | 66 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c index d02d7af7b9..b0c32445b0 100644 --- a/dlls/comctl32/edit.c +++ b/dlls/comctl32/edit.c @@ -406,7 +406,7 @@ static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, IN
static inline INT get_vertical_line_count(EDITSTATE *es) { - INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; + INT vlc = es->line_height ? (es->format_rect.bottom - es->format_rect.top) / es->line_height : 0; return max(1,vlc); }
@@ -1543,7 +1543,7 @@ static void EDIT_UpdateScrollInfo(EDITSTATE *es) si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL; si.nMin = 0; si.nMax = es->line_count - 1; - si.nPage = (es->format_rect.bottom - es->format_rect.top) / es->line_height; + si.nPage = es->line_height ? (es->format_rect.bottom - es->format_rect.top) / es->line_height : 0; si.nPos = es->y_offset; TRACE("SB_VERT, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n", si.nMin, si.nMax, si.nPage, si.nPos); diff --git a/dlls/comctl32/tests/edit.c b/dlls/comctl32/tests/edit.c index cec6025077..763ade4831 100644 --- a/dlls/comctl32/tests/edit.c +++ b/dlls/comctl32/tests/edit.c @@ -1768,6 +1768,71 @@ static BOOL is_font_installed(const char*name) return ret; }
+static WNDPROC orig_class_proc; + +static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + RECT rect; + LRESULT result, r; + + switch (message) + { + case WM_NCCREATE: + result = CallWindowProcA(orig_class_proc, hwnd, message, wParam, lParam); + + memset(&rect, 0, sizeof(rect)); + SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rect); + ok(!rect.right && !rect.bottom, "Invalid size after NCCREATE: %d x %d\n", rect.right, rect.bottom); + + /* test that messages between WM_NCCREATE and WM_CREATE + don't crash or cause unexpected behavior */ + r = SendMessageA(hwnd, EM_SETSEL, 0, 0); + ok(r == 1, "Returned %ld, expected 1.\n", r); + r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010); + todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r); + + return result; + + case WM_CREATE: + /* test that messages between WM_NCCREATE and WM_CREATE + don't crash or cause unexpected behavior */ + r = SendMessageA(hwnd, EM_SETSEL, 0, 0); + ok(r == 1, "Returned %ld, expected 1.\n", r); + r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010); + todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r); + + break; + } + + return CallWindowProcA(orig_class_proc, hwnd, message, wParam, lParam); +} + +static void test_initialization(void) +{ + BOOL ret; + ATOM atom; + HWND hwEdit; + WNDCLASSA cls; + + ret = GetClassInfoA(NULL, "Edit", &cls); + ok(ret, "Failed to get class info.\n"); + + orig_class_proc = cls.lpfnWndProc; + cls.lpfnWndProc = test_class_proc; + cls.lpszClassName = "TestClassName"; + + atom = RegisterClassA(&cls); + ok(atom != 0, "Failed to register class.\n"); + + hwEdit = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atom), "Text Text", + ES_MULTILINE | WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL | WS_VSCROLL, + 10, 10, 300, 300, NULL, NULL, hinst, NULL); + ok(hwEdit != NULL, "Failed to create a window.\n"); + + DestroyWindow(hwEdit); + UnregisterClassA((LPCSTR)MAKEINTATOM(atom), hinst); +} + static void test_margins(void) { DWORD old_margins, new_margins; @@ -3393,6 +3458,7 @@ START_TEST(edit) test_edit_control_6(); test_edit_control_limittext(); test_edit_control_scroll(); + test_initialization(); test_margins(); test_margins_font_change(); test_text_position();
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=19239 Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/user32/edit.c | 4 +-- dlls/user32/tests/edit.c | 66 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index 557a091c0d..aba6a084a2 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -465,7 +465,7 @@ static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, IN
static inline INT get_vertical_line_count(EDITSTATE *es) { - INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; + INT vlc = es->line_height ? (es->format_rect.bottom - es->format_rect.top) / es->line_height : 0; return max(1,vlc); }
@@ -1638,7 +1638,7 @@ static void EDIT_UpdateScrollInfo(EDITSTATE *es) si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL; si.nMin = 0; si.nMax = es->line_count - 1; - si.nPage = (es->format_rect.bottom - es->format_rect.top) / es->line_height; + si.nPage = es->line_height ? (es->format_rect.bottom - es->format_rect.top) / es->line_height : 0; si.nPos = es->y_offset; TRACE("SB_VERT, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n", si.nMin, si.nMax, si.nPage, si.nPos); diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index e3ed3341d6..2289bbf03f 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -1743,6 +1743,71 @@ static BOOL is_font_installed(const char*name) return ret; }
+static WNDPROC orig_class_proc; + +static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + RECT rect; + LRESULT result, r; + + switch (message) + { + case WM_NCCREATE: + result = CallWindowProcA(orig_class_proc, hwnd, message, wParam, lParam); + + memset(&rect, 0, sizeof(rect)); + SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rect); + ok(!rect.right && !rect.bottom, "Invalid size after NCCREATE: %d x %d\n", rect.right, rect.bottom); + + /* test that messages between WM_NCCREATE and WM_CREATE + don't crash or cause unexpected behavior */ + r = SendMessageA(hwnd, EM_SETSEL, 0, 0); + ok(r == 1, "Returned %ld, expected 1.\n", r); + r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010); + todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r); + + return result; + + case WM_CREATE: + /* test that messages between WM_NCCREATE and WM_CREATE + don't crash or cause unexpected behavior */ + r = SendMessageA(hwnd, EM_SETSEL, 0, 0); + ok(r == 1, "Returned %ld, expected 1.\n", r); + r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010); + todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r); + + break; + } + + return CallWindowProcA(orig_class_proc, hwnd, message, wParam, lParam); +} + +static void test_initialization(void) +{ + BOOL ret; + ATOM atom; + HWND hwEdit; + WNDCLASSA cls; + + ret = GetClassInfoA(NULL, "Edit", &cls); + ok(ret, "Failed to get class info.\n"); + + orig_class_proc = cls.lpfnWndProc; + cls.lpfnWndProc = test_class_proc; + cls.lpszClassName = "TestClassName"; + + atom = RegisterClassA(&cls); + ok(atom != 0, "Failed to register class.\n"); + + hwEdit = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atom), "Text Text", + ES_MULTILINE | WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL | WS_VSCROLL, + 10, 10, 300, 300, NULL, NULL, hinst, NULL); + ok(hwEdit != NULL, "Failed to create a window.\n"); + + DestroyWindow(hwEdit); + UnregisterClassA((LPCSTR)MAKEINTATOM(atom), hinst); +} + static void test_margins(void) { HWND hwEdit; @@ -3268,6 +3333,7 @@ START_TEST(edit) test_edit_control_6(); test_edit_control_limittext(); test_edit_control_scroll(); + test_initialization(); test_margins(); test_margins_font_change(); test_text_position();
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/comctl32/edit.c | 8 ++++++-- dlls/comctl32/tests/edit.c | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c index b0c32445b0..4861fd7a9c 100644 --- a/dlls/comctl32/edit.c +++ b/dlls/comctl32/edit.c @@ -1579,8 +1579,12 @@ static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy) { INT nyoff; INT x_offset_in_pixels; - INT lines_per_page = (es->format_rect.bottom - es->format_rect.top) / - es->line_height; + INT lines_per_page; + + if (!es->line_height || !es->char_width) + return TRUE; + + lines_per_page = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
if (es->style & ES_MULTILINE) { diff --git a/dlls/comctl32/tests/edit.c b/dlls/comctl32/tests/edit.c index 763ade4831..e3b2f40804 100644 --- a/dlls/comctl32/tests/edit.c +++ b/dlls/comctl32/tests/edit.c @@ -1790,6 +1790,8 @@ static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam, ok(r == 1, "Returned %ld, expected 1.\n", r); r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010); todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r); + r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1); + ok(r == 1, "Returned %ld, expected 1.\n", r);
return result;
@@ -1800,6 +1802,8 @@ static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam, ok(r == 1, "Returned %ld, expected 1.\n", r); r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010); todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r); + r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1); + ok(r == 1, "Returned %ld, expected 1.\n", r);
break; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/user32/edit.c | 8 ++++++-- dlls/user32/tests/edit.c | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index aba6a084a2..683c2faea3 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -1674,8 +1674,12 @@ static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy) { INT nyoff; INT x_offset_in_pixels; - INT lines_per_page = (es->format_rect.bottom - es->format_rect.top) / - es->line_height; + INT lines_per_page; + + if (!es->line_height || !es->char_width) + return TRUE; + + lines_per_page = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
if (es->style & ES_MULTILINE) { diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index 2289bbf03f..34bb1e5a76 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -1765,6 +1765,8 @@ static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam, ok(r == 1, "Returned %ld, expected 1.\n", r); r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010); todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r); + r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1); + ok(r == 1, "Returned %ld, expected 1.\n", r);
return result;
@@ -1775,6 +1777,8 @@ static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam, ok(r == 1, "Returned %ld, expected 1.\n", r); r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010); todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r); + r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1); + ok(r == 1, "Returned %ld, expected 1.\n", r);
break; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com