[PATCH 1/8] riched20: Move the editor initialization out of CreateTextHost().
Huw Davies
huw at codeweavers.com
Mon Aug 21 06:31:44 CDT 2017
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/riched20/editor.c | 32 ++++++++++++++++++++++++++------
dlls/riched20/txthost.c | 23 +++++++----------------
2 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 1ce444e604..f5b9e4c0d0 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -4792,6 +4792,30 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
return 0L;
}
+static BOOL create_windowed_editor(HWND hwnd, CREATESTRUCTW *create, BOOL emulate_10)
+{
+ ITextHost *host = ME_CreateTextHost( hwnd, create, emulate_10 );
+ ME_TextEditor *editor;
+
+ if (!host) return FALSE;
+
+ editor = ME_MakeEditor( host, emulate_10, create->style );
+ if (!editor)
+ {
+ ITextHost_Release( host );
+ return FALSE;
+ }
+
+ editor->exStyleFlags = GetWindowLongW( hwnd, GWL_EXSTYLE );
+ editor->styleFlags |= GetWindowLongW( hwnd, GWL_STYLE ) & ES_WANTRETURN;
+ editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
+ editor->hwndParent = create->hwndParent;
+
+ SetWindowLongPtrW( hwnd, 0, (LONG_PTR)editor );
+
+ return TRUE;
+}
+
static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
LPARAM lParam, BOOL unicode)
{
@@ -4808,11 +4832,9 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
if (msg == WM_NCCREATE)
{
CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam;
- ITextHost *texthost;
TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style);
- texthost = ME_CreateTextHost(hWnd, pcs, FALSE);
- return texthost != NULL;
+ return create_windowed_editor( hWnd, pcs, FALSE );
}
else
{
@@ -4938,12 +4960,10 @@ LRESULT WINAPI RichEdit10ANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
{
if (msg == WM_NCCREATE && !GetWindowLongPtrW(hWnd, 0))
{
- ITextHost *texthost;
CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam;
TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style);
- texthost = ME_CreateTextHost(hWnd, pcs, TRUE);
- return texthost != NULL;
+ return create_windowed_editor( hWnd, pcs, TRUE );
}
return RichEditANSIWndProc(hWnd, msg, wParam, lParam);
}
diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index 0e51ecf850..ccd554d6e0 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -45,23 +45,14 @@ static const ITextHostVtbl textHostVtbl;
ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10)
{
ITextHostImpl *texthost;
+
texthost = CoTaskMemAlloc(sizeof(*texthost));
- if (texthost)
- {
- ME_TextEditor *editor;
-
- texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
- texthost->ref = 1;
- texthost->hWnd = hwnd;
- texthost->bEmulateVersion10 = bEmulateVersion10;
-
- editor = ME_MakeEditor(&texthost->ITextHost_iface, bEmulateVersion10, cs->style);
- editor->exStyleFlags = GetWindowLongW(hwnd, GWL_EXSTYLE);
- editor->styleFlags |= GetWindowLongW(hwnd, GWL_STYLE) & ES_WANTRETURN;
- editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
- editor->hwndParent = cs->hwndParent;
- SetWindowLongPtrW(hwnd, 0, (LONG_PTR)editor);
- }
+ if (!texthost) return NULL;
+
+ texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
+ texthost->ref = 1;
+ texthost->hWnd = hwnd;
+ texthost->bEmulateVersion10 = bEmulateVersion10;
return &texthost->ITextHost_iface;
}
--
2.12.0
More information about the wine-patches
mailing list