diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 253c7b8b93f..f3046c9cb11 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2741,8 +2741,9 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ME_GetSelection(editor, &from, &to); style = ME_GetSelectionInsertStyle(editor); ME_InternalDeleteText(editor, from, to - from, FALSE); - if (pStruct->codepage != 1200 && lParam && !strncmp((char *)lParam, "{\\rtf", 5)) - ME_StreamInRTFString(editor, 1, (char *)lParam); + if (pStruct->codepage != 1200 && lParam && + (!strncmp((char *)lParam, "{\\rtf", 5) || !strncmp((char *)lParam, "{\\urtf}", 6))) + ME_StreamInRTFString(editor, 1, (char *)lParam); else ME_InsertTextFromCursor(editor, 0, wszText, len, style); ME_ReleaseStyle(style); @@ -2750,8 +2751,9 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, } else { ME_InternalDeleteText(editor, 0, ME_GetTextLength(editor), FALSE); - if (pStruct->codepage != 1200 && lParam && !strncmp((char *)lParam, "{\\rtf", 5)) - ME_StreamInRTFString(editor, 0, (char *)lParam); + if (pStruct->codepage != 1200 && lParam && + (!strncmp((char *)lParam, "{\\rtf", 5) || !strncmp((char *)lParam, "{\\urtf}", 6))) + ME_StreamInRTFString(editor, 0, (char *)lParam); else ME_InsertTextFromCursor(editor, 0, wszText, len, editor->pBuffer->pDefaultStyle); len = 1; diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 87e67da4e17..54b100c7e56 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -3522,6 +3522,28 @@ static void test_EM_SETTEXTEX(void) "EM_GETTEXTEX results not what was set by EM_SETTEXTEX when" " using ST_SELECTION and non-Unicode\n"); + /* Test setting text using rich text format */ + setText.flags = 0; + setText.codepage = CP_ACP; + SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM)"{\\rtf richtext}"); + getText.codepage = CP_ACP; + getText.cb = MAX_BUF_LEN; + getText.flags = GT_DEFAULT; + getText.lpDefaultChar = NULL; + getText.lpUsedDefChar = NULL; + SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) bufACP); + ok(!strcmp(bufACP, "richtext"), "expected 'richtext' but got '%s'\n", bufACP); + + setText.flags = 0; + setText.codepage = CP_ACP; + SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM)"{\\urtf morerichtext}"); + getText.codepage = CP_ACP; + getText.cb = MAX_BUF_LEN; + getText.flags = GT_DEFAULT; + getText.lpDefaultChar = NULL; + getText.lpUsedDefChar = NULL; + SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) bufACP); + ok(!strcmp(bufACP, "morerichtext"), "expected 'morerichtext' but got '%s'\n", bufACP); DestroyWindow(hwndRichEdit); }