Module: wine Branch: master Commit: f54aa40746d230feb4068936e2ceb7511695b0dd URL: http://source.winehq.org/git/wine.git/?a=commit;h=f54aa40746d230feb4068936e2...
Author: Alex Villacís Lasso a_villacis@palosanto.com Date: Thu Oct 18 11:02:09 2007 -0500
riched20: Single-line control must refuse to insert carriage returns (with tests).
---
dlls/riched20/editor.c | 4 ++- dlls/riched20/tests/editor.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 81fe9b2..eabaa8d 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2431,7 +2431,9 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, SendMessageW(editor->hWnd, EM_UNDO, 0, 0); return 0; } - if (((unsigned)wstr)>=' ' || wstr=='\r' || wstr=='\t') { + if (((unsigned)wstr)>=' ' + || (wstr=='\r' && (GetWindowLongW(hWnd, GWL_STYLE) & ES_MULTILINE)) + || wstr=='\t') { /* FIXME maybe it would make sense to call EM_REPLACESEL instead ? */ /* WM_CHAR is restricted to nTextLimit */ int from, to; diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 5375d30..90899e0 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -2058,6 +2058,56 @@ static void test_unicode_conversions(void) DestroyWindow(hwnd); }
+static void test_WM_CHAR(void) +{ + HWND hwnd; + int ret; + const char * char_list = "abc\rabc\r"; + const char * expected_content_single = "abcabc"; + const char * expected_content_multi = "abc\r\nabc\r\n"; + char buffer[64] = {0}; + const char * p; + + /* single-line control must IGNORE carriage returns */ + hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP, + 0, 0, 200, 60, 0, 0, 0, 0); + ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); + + p = char_list; + while (*p != '\0') { + SendMessageA(hwnd, WM_KEYDOWN, *p, 1); + ret = SendMessageA(hwnd, WM_CHAR, *p, 1); + ok(ret == 0, "WM_CHAR('%c') ret=%d\n", *p, ret); + SendMessageA(hwnd, WM_KEYUP, *p, 1); + p++; + } + + SendMessage(hwnd, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer); + ret = strcmp(buffer, expected_content_single); + ok(ret == 0, "WM_GETTEXT recovered incorrect string!\n"); + + DestroyWindow(hwnd); + + /* multi-line control inserts CR normally */ + hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP|ES_MULTILINE, + 0, 0, 200, 60, 0, 0, 0, 0); + ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); + + p = char_list; + while (*p != '\0') { + SendMessageA(hwnd, WM_KEYDOWN, *p, 1); + ret = SendMessageA(hwnd, WM_CHAR, *p, 1); + ok(ret == 0, "WM_CHAR('%c') ret=%d\n", *p, ret); + SendMessageA(hwnd, WM_KEYUP, *p, 1); + p++; + } + + SendMessage(hwnd, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer); + ret = strcmp(buffer, expected_content_multi); + ok(ret == 0, "WM_GETTEXT recovered incorrect string!\n"); + + DestroyWindow(hwnd); +}
static void test_EM_GETTEXTLENGTHEX(void) { @@ -2205,6 +2255,7 @@ START_TEST( editor ) hmoduleRichEdit = LoadLibrary("RICHED20.DLL"); ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
+ test_WM_CHAR(); test_EM_FINDTEXT(); test_EM_GETLINE(); test_EM_SCROLLCARET();