riched20: Minimal fix for WM_SETTEXT without ES_MULTILINE style.

This commit is contained in:
Alex Villacís Lasso 2007-09-27 18:17:48 -05:00 committed by Alexandre Julliard
parent 2055e636ae
commit 63b12f8602
2 changed files with 22 additions and 5 deletions

View File

@ -1908,8 +1908,18 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
TRACE("WM_SETTEXT - %s\n", debugstr_w(wszText)); /* debugstr_w() */
if (lstrlenW(wszText) > 0)
{
int len = -1;
/* uses default style! */
ME_InsertTextFromCursor(editor, 0, wszText, -1, editor->pBuffer->pDefaultStyle);
if (!(GetWindowLongW(hWnd, GWL_STYLE) & ES_MULTILINE))
{
WCHAR * p;
p = wszText;
while (*p != '\0' && *p != '\r' && *p != '\n') p++;
len = p - wszText;
}
ME_InsertTextFromCursor(editor, 0, wszText, len, editor->pBuffer->pDefaultStyle);
}
ME_EndToUnicode(unicode, wszText);
}

View File

@ -2064,6 +2064,9 @@ static void test_EM_GETTEXTLENGTHEX(void)
HWND hwnd;
GETTEXTLENGTHEX gtl;
int ret;
const char * test_string = "a\nb\n\n\r\n";
const char * test_string_after = "a";
char buffer[64] = {0};
/* single line */
hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP,
@ -2080,17 +2083,21 @@ static void test_EM_GETTEXTLENGTHEX(void)
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
ok(ret == 0, "ret %d\n",ret);
SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) "a\nb\n\n\r\n");
SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string);
gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF;
gtl.codepage = CP_ACP;
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
todo_wine ok(ret == 1, "ret %d\n",ret);
ok(ret == 1, "ret %d\n",ret);
gtl.flags = GTL_NUMCHARS | GTL_PRECISE;
gtl.codepage = CP_ACP;
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
todo_wine ok(ret == 1, "ret %d\n",ret);
ok(ret == 1, "ret %d\n",ret);
SendMessage(hwnd, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer);
ret = strcmp(buffer, test_string_after);
ok(ret == 0, "WM_GETTEXT recovered incorrect string!\n");
DestroyWindow(hwnd);
@ -2109,7 +2116,7 @@ static void test_EM_GETTEXTLENGTHEX(void)
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
ok(ret == 0, "ret %d\n",ret);
SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) "a\nb\n\n\r\n");
SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string);
gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF;
gtl.codepage = CP_ACP;