Piotr Caban : riched20: Set control content in WM_CREATE message.
Alexandre Julliard
julliard at winehq.org
Mon Oct 7 14:17:12 CDT 2013
Module: wine
Branch: master
Commit: e660bf676c111ce20d9e868280094f1c5bb81c79
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e660bf676c111ce20d9e868280094f1c5bb81c79
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Oct 7 15:28:00 2013 +0200
riched20: Set control content in WM_CREATE message.
---
dlls/riched20/editor.c | 24 ++++++++++++++++++++++++
dlls/riched20/tests/editor.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 42f5770..6e7ffae 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3999,6 +3999,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
}
case WM_CREATE:
{
+ void *text = NULL;
INT max;
ME_SetDefaultFormatRect(editor);
@@ -4024,6 +4025,29 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
}
}
+ if (lParam)
+ {
+ text = (unicode ? (void*)((CREATESTRUCTW*)lParam)->lpszName
+ : (void*)((CREATESTRUCTA*)lParam)->lpszName);
+ }
+ if (text)
+ {
+ WCHAR *textW;
+ int len;
+
+ textW = ME_ToUnicode(unicode, text, &len);
+ if (!(editor->styleFlags & ES_MULTILINE))
+ {
+ len = 0;
+ while(textW[len] != '0' && textW[len] != '\r' && textW[len] != '\n')
+ len++;
+ }
+ ME_InsertTextFromCursor(editor, 0, textW, len, editor->pBuffer->pDefaultStyle);
+ ME_EndToUnicode(unicode, textW);
+ ME_SetCursorToStart(editor, &editor->pCursors[0]);
+ ME_SetCursorToStart(editor, &editor->pCursors[1]);
+ }
+
ME_CommitUndo(editor);
ME_WrapMarkedParagraphs(editor);
ME_MoveCaret(editor);
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 35684e6..4d9fde6 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -7410,6 +7410,43 @@ static void test_enter(void)
DestroyWindow(hwndRichEdit);
}
+static void test_WM_CREATE(void)
+{
+ static const WCHAR titleW[] = {'l','i','n','e','1','\n','l','i','n','e','2',0};
+ static const char title[] = "line1\nline2";
+
+ HWND rich_edit;
+ LRESULT res;
+ char buf[64];
+ int len;
+
+ rich_edit = CreateWindowA(RICHEDIT_CLASS20A, title, WS_POPUP|WS_VISIBLE,
+ 0, 0, 200, 80, NULL, NULL, NULL, NULL);
+ ok(rich_edit != NULL, "class: %s, error: %d\n", RICHEDIT_CLASS20A, (int) GetLastError());
+
+ len = GetWindowText(rich_edit, buf, sizeof(buf));
+ ok(len == 5, "GetWindowText returned %d\n", len);
+ ok(!strcmp(buf, "line1"), "buf = %s\n", buf);
+
+ res = SendMessage(rich_edit, EM_GETSEL, 0, 0);
+ ok(res == 0, "SendMessage(EM_GETSEL) returned %lx\n", res);
+
+ DestroyWindow(rich_edit);
+
+ rich_edit = CreateWindowW(RICHEDIT_CLASS20W, titleW, WS_POPUP|WS_VISIBLE|ES_MULTILINE,
+ 0, 0, 200, 80, NULL, NULL, NULL, NULL);
+ ok(rich_edit != NULL, "class: %s, error: %d\n", wine_dbgstr_w(RICHEDIT_CLASS20W), (int) GetLastError());
+
+ len = GetWindowText(rich_edit, buf, sizeof(buf));
+ ok(len == 12, "GetWindowText returned %d\n", len);
+ ok(!strcmp(buf, "line1\r\nline2"), "buf = %s\n", buf);
+
+ res = SendMessage(rich_edit, EM_GETSEL, 0, 0);
+ ok(res == 0, "SendMessage(EM_GETSEL) returned %lx\n", res);
+
+ DestroyWindow(rich_edit);
+}
+
START_TEST( editor )
{
BOOL ret;
@@ -7470,6 +7507,7 @@ START_TEST( editor )
test_EM_FINDWORDBREAK_W();
test_EM_FINDWORDBREAK_A();
test_enter();
+ test_WM_CREATE();
/* Set the environment variable WINETEST_RICHED20 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
More information about the wine-cvs
mailing list