From c40562307cf044ed6cfca35dd10f818d0ff3aa1a Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Thu, 9 Jun 2005 20:32:32 +0000 Subject: [PATCH] Add more tests for text placement in single and multiline edit controls. Some of the tests are marked as todo. --- dlls/user/edit.c | 29 ++-- dlls/user/tests/edit.c | 338 +++++++++++++++++++++++++++++------------ 2 files changed, 253 insertions(+), 114 deletions(-) diff --git a/dlls/user/edit.c b/dlls/user/edit.c index 95296ffda50..1f7ecbbe84c 100644 --- a/dlls/user/edit.c +++ b/dlls/user/edit.c @@ -2216,26 +2216,9 @@ static void EDIT_SetRectNP(EDITSTATE *es, LPRECT rc) LONG_PTR ExStyle; CopyRect(&es->format_rect, rc); - if (es->style & ES_MULTILINE) - { + ExStyle = GetWindowLongPtrW(es->hwndSelf, GWL_EXSTYLE); + if ((es->style & WS_POPUP) && !(ExStyle & WS_EX_CLIENTEDGE)) { if (es->style & WS_BORDER) { - INT bw = GetSystemMetrics(SM_CXBORDER) + 1; - es->format_rect.left += bw; - es->format_rect.right -= bw; - es->format_rect.top += bw; - es->format_rect.bottom -= bw; - } - } - else - { - ExStyle = GetWindowLongPtrW(es->hwndSelf, GWL_EXSTYLE); - if (ExStyle & WS_EX_CLIENTEDGE) { - if (es->line_height + 2 <= - es->format_rect.bottom - es->format_rect.top) { - es->format_rect.top++; - es->format_rect.bottom--; - } - } else if (es->style & WS_BORDER) { INT bw = GetSystemMetrics(SM_CXBORDER) + 1; es->format_rect.left += bw; es->format_rect.right -= bw; @@ -2245,6 +2228,14 @@ static void EDIT_SetRectNP(EDITSTATE *es, LPRECT rc) es->format_rect.bottom -= bw; } } + } else { + if (es->line_height + 2 <= + es->format_rect.bottom - es->format_rect.top) { + es->format_rect.top++; + es->format_rect.bottom--; + } + es->format_rect.left++; + es->format_rect.right--; } es->format_rect.left += es->left_margin; es->format_rect.right -= es->right_margin; diff --git a/dlls/user/tests/edit.c b/dlls/user/tests/edit.c index a44afa5f994..cd82348bedc 100644 --- a/dlls/user/tests/edit.c +++ b/dlls/user/tests/edit.c @@ -93,6 +93,25 @@ static void set_client_height(HWND Wnd, unsigned Height) SWP_NOMOVE | SWP_NOZORDER); } +#define edit_pos_ok(exp, got, txt) \ + ok(exp == got, "wrong " #txt " expected %d got %ld\n", exp, got); + +#define edit_todo_pos_ok(exp, got, txt, todo) \ + if (todo) todo_wine { edit_pos_ok(exp, got, txt); } \ + else edit_pos_ok(exp, got, txt) + +#define check_pos(hwEdit, set_height, test_top, test_height, test_left, todo_top, todo_height, todo_left) \ +do { \ + RECT format_rect; \ + int left_margin; \ + set_client_height(hwEdit, set_height); \ + SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &format_rect); \ + left_margin = LOWORD(SendMessage(hwEdit, EM_GETMARGINS, 0, 0)); \ + edit_todo_pos_ok(test_top, format_rect.top, vertical position, todo_top); \ + edit_todo_pos_ok((int)test_height, format_rect.bottom - format_rect.top, height, todo_height); \ + edit_todo_pos_ok(test_left, format_rect.left - left_margin, left, todo_left); \ +} while(0) + static void test_edit_control_1(void) { HWND hwEdit; @@ -102,7 +121,6 @@ static void test_edit_control_1(void) HFONT Font, OldFont; HDC Dc; TEXTMETRIC Metrics; - RECT FormatRect; msMessage.message = WM_KEYDOWN; @@ -172,113 +190,244 @@ static void test_edit_control_1(void) SelectObject(Dc, OldFont); ReleaseDC(NULL, Dc); - trace("EDIT: vertical text position\n"); + trace("EDIT: Text position\n"); + hwEdit = create_editcontrol(0, 0); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_BORDER, 0); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 1, 1, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 1, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 1, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(0, WS_EX_CLIENTEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_BORDER, WS_EX_CLIENTEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(0, WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_BORDER, WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 1, 1, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 1, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 1, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(0, WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_BORDER, WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + hwEdit = create_editcontrol(WS_POPUP, 0); SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - set_client_height(hwEdit, Metrics.tmHeight - 1); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight - 1 == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight - 1, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 1); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 2); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 10); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 0, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 0, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 0, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 0, Metrics.tmHeight , 0, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 0, Metrics.tmHeight , 0, 0, 0, 0); DestroyWindow(hwEdit); hwEdit = create_editcontrol(WS_POPUP | WS_BORDER, 0); SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - set_client_height(hwEdit, Metrics.tmHeight - 1); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight - 1 == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight - 1, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 2); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 3); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 4); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(2 == FormatRect.top, "wrong vertical position expected 2 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 10); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(2 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 0, Metrics.tmHeight , 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 3, 0, Metrics.tmHeight , 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 2, Metrics.tmHeight , 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 2, Metrics.tmHeight , 2, 0, 0, 0); DestroyWindow(hwEdit); hwEdit = create_editcontrol(WS_POPUP, WS_EX_CLIENTEDGE); SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - set_client_height(hwEdit, Metrics.tmHeight - 1); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight - 1 == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight - 1, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 1); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 2); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(1 == FormatRect.top, "wrong vertical position expected 1 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 4); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(1 == FormatRect.top, "wrong vertical position expected 1 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 10); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(1 == FormatRect.top, "wrong vertical position expected 1 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); DestroyWindow(hwEdit); hwEdit = create_editcontrol(WS_POPUP | WS_BORDER, WS_EX_CLIENTEDGE); SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - set_client_height(hwEdit, Metrics.tmHeight - 1); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight - 1 == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight - 1, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 1); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(0 == FormatRect.top, "wrong vertical position expected 0 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 2); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(1 == FormatRect.top, "wrong vertical position expected 1 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 4); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(1 == FormatRect.top, "wrong vertical position expected 1 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); - set_client_height(hwEdit, Metrics.tmHeight + 10); - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &FormatRect); - ok(1 == FormatRect.top, "wrong vertical position expected 1 got %ld\n", FormatRect.top); - ok(Metrics.tmHeight == FormatRect.bottom - FormatRect.top, "wrong height expected %ld got %ld\n", Metrics.tmHeight, FormatRect.bottom - FormatRect.top); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_POPUP, WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 0, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 0, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 0, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 0, Metrics.tmHeight , 0, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 0, Metrics.tmHeight , 0, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 0, Metrics.tmHeight , 0, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_POPUP | WS_BORDER, WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 0, Metrics.tmHeight , 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 3, 0, Metrics.tmHeight , 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 2, Metrics.tmHeight , 2, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 2, Metrics.tmHeight , 2, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_POPUP, WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_POPUP | WS_BORDER, WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(0, ES_MULTILINE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_BORDER, ES_MULTILINE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 1, 1, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 1, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 1, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(0, ES_MULTILINE | WS_EX_CLIENTEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_BORDER, ES_MULTILINE | WS_EX_CLIENTEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(0, ES_MULTILINE | WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_BORDER, ES_MULTILINE | WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 1, 1, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 1, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 1, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(0, ES_MULTILINE | WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(WS_BORDER, ES_MULTILINE | WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); + check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); + check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); DestroyWindow(hwEdit); } @@ -401,7 +550,6 @@ static LRESULT CALLBACK edit3_wnd_procA(HWND hWnd, UINT msg, WPARAM wParam, LPAR return DefWindowProcA(hWnd, msg, wParam, lParam); } - /* Test behaviour of WM_SETTEXT, WM_REPLACESEL and notificatisons sent in response * to these messages. */