Fabian Maurer : riched32: Handle enter press in WM_CHAR instead of WM_KEYDOWN.
Alexandre Julliard
julliard at winehq.org
Wed Dec 12 15:16:20 CST 2018
Module: wine
Branch: master
Commit: 52c106418c60141ab816b065eb156df271218228
URL: https://source.winehq.org/git/wine.git/?a=commit;h=52c106418c60141ab816b065eb156df271218228
Author: Fabian Maurer <dark.shadow4 at web.de>
Date: Wed Dec 12 11:48:00 2018 +0000
riched32: Handle enter press in WM_CHAR instead of WM_KEYDOWN.
This fixes an old regression when VK_RETURN handling was implemented
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=23282
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/riched20/editor.c | 16 +++++++++++-----
dlls/riched20/tests/editor.c | 29 +++++++++++++++++++++++++++++
dlls/riched32/tests/editor.c | 29 +++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 5 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 79c9636..9bacc63 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2668,7 +2668,9 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
ME_SendRequestResize(editor, FALSE);
return TRUE;
case VK_RETURN:
- return handle_enter(editor);
+ if (!editor->bEmulateVersion10)
+ return handle_enter(editor);
+ break;
case VK_ESCAPE:
if (editor->bDialogMode && editor->hwndParent)
PostMessageW(editor->hwndParent, WM_CLOSE, 0, 0);
@@ -2740,6 +2742,12 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
if (editor->bMouseCaptured)
return 0;
+ if (editor->styleFlags & ES_READONLY)
+ {
+ MessageBeep(MB_ICONERROR);
+ return 0; /* FIXME really 0 ? */
+ }
+
if (unicode)
wstr = (WCHAR)charCode;
else
@@ -2748,10 +2756,8 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
MultiByteToWideChar(CP_ACP, 0, &charA, 1, &wstr, 1);
}
- if (editor->styleFlags & ES_READONLY) {
- MessageBeep(MB_ICONERROR);
- return 0; /* FIXME really 0 ? */
- }
+ if (editor->bEmulateVersion10 && wstr == '\r')
+ handle_enter(editor);
if ((unsigned)wstr >= ' ' || wstr == '\t')
{
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 782d6d8..932c8a1 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -8273,6 +8273,7 @@ static void format_test_result(char *target, const char *src)
* inserts CR. If shows that EM_GETTEXTEX with GT_USECRLF == WM_GETTEXT
* and also shows that GT_USECRLF has no effect in richedit 1.0, but
* does for higher. The same test is cloned in riched32 and riched20.
+ * Also shows the difference between WM_CHAR/WM_KEYDOWN in v1.0 and higher versions
*/
static void test_enter(void)
{
@@ -8353,6 +8354,34 @@ static void test_enter(void)
i, resultbuf, expectedbuf);
}
+ /* Show that WM_CHAR is handled differently from WM_KEYDOWN */
+ getText.flags = GT_DEFAULT;
+ getText.codepage = CP_ACP;
+
+ result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"");
+ ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result);
+ SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0);
+ SendMessageW(hwndRichEdit, WM_KEYDOWN, VK_RETURN, 0);
+
+ result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);
+ ok(result == 2, "Got %d\n", (int)result);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, "T\r");
+ result = strcmp(resultbuf, expectedbuf);
+ ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf);
+
+ result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"");
+ ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result);
+ SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0);
+ SendMessageW(hwndRichEdit, WM_CHAR, '\r', 0);
+
+ result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);
+ ok(result == 1, "Got %d\n", (int)result);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, "T");
+ result = strcmp(resultbuf, expectedbuf);
+ ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf);
+
DestroyWindow(hwndRichEdit);
}
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index a60d21b..dd9773c 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -1163,6 +1163,7 @@ static void format_test_result(char *target, const char *src)
* inserts CR. If shows that EM_GETTEXTEX with GT_USECRLF == WM_GETTEXT
* and also shows that GT_USECRLF has no effect in richedit 1.0, but
* does for higher. The same test is cloned in riched32 and riched20.
+ * Also shows the difference between WM_CHAR/WM_KEYDOWN in v1.0 and higher versions
*/
static void test_enter(void)
{
@@ -1241,6 +1242,34 @@ static void test_enter(void)
i, resultbuf, expectedbuf);
}
+ /* Show that WM_CHAR is handled differently from WM_KEYDOWN */
+ getText.flags = GT_DEFAULT;
+ getText.codepage = CP_ACP;
+
+ result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"");
+ ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result);
+ SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0);
+ SendMessageW(hwndRichEdit, WM_KEYDOWN, VK_RETURN, 0);
+
+ result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);
+ ok(result == 1, "Got %d\n", (int)result);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, "T");
+ result = strcmp(resultbuf, expectedbuf);
+ ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf);
+
+ result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"");
+ ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result);
+ SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0);
+ SendMessageW(hwndRichEdit, WM_CHAR, '\r', 0);
+
+ SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);
+ ok(result == 1, "Got %d\n", (int)result);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, "T\r\n");
+ result = strcmp(resultbuf, expectedbuf);
+ ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf);
+
DestroyWindow(hwndRichEdit);
}
More information about the wine-cvs
mailing list