diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 1ffb1eacad3..d30ba9de412 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1996,7 +1996,13 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, return 0; } case WM_GETTEXTLENGTH: - return ME_GetTextLength(editor); + { + GETTEXTLENGTHEX how; + + how.flags = GTL_CLOSE | GTL_USECRLF | GTL_NUMCHARS; + how.codepage = unicode ? 1200 : CP_ACP; + return ME_GetTextLengthEx(editor, &how); + } case EM_GETTEXTLENGTHEX: return ME_GetTextLengthEx(editor, (GETTEXTLENGTHEX *)wParam); case WM_GETTEXT: diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 5512017d0b9..c3d09bff531 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -671,6 +671,12 @@ static void test_WM_GETTEXT(void) ok(result == 0, "WM_GETTEXT: settext and gettext differ. strcmp: %d\n", result); + /* Test for returned value of WM_GETTEXTLENGTH */ + result = SendMessage(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0); + ok(result == strlen(text), + "WM_GETTEXTLENGTH reports incorrect length %d, expected %d\n", + result, strlen(text)); + /* Test for behavior in overflow case */ memset(buffer, 0, 1024); result = SendMessage(hwndRichEdit, WM_GETTEXT, strlen(text), (LPARAM)buffer); @@ -689,6 +695,12 @@ static void test_WM_GETTEXT(void) ok(result == 0, "WM_GETTEXT: settext and gettext differ. strcmp: %d\n", result); + /* Test for returned value of WM_GETTEXTLENGTH */ + result = SendMessage(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0); + ok(result == strlen(text2_after), + "WM_GETTEXTLENGTH reports incorrect length %d, expected %d\n", + result, strlen(text2_after)); + /* Test for behavior of CRLF conversion in case of overflow */ memset(buffer, 0, 1024); result = SendMessage(hwndRichEdit, WM_GETTEXT, strlen(text2), (LPARAM)buffer);