Commit 4cb7578d authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Move the editor initialization out of CreateTextHost().

parent 267bca1f
...@@ -4792,6 +4792,30 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, ...@@ -4792,6 +4792,30 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
return 0L; 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, static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
LPARAM lParam, BOOL unicode) LPARAM lParam, BOOL unicode)
{ {
...@@ -4808,11 +4832,9 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ...@@ -4808,11 +4832,9 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
if (msg == WM_NCCREATE) if (msg == WM_NCCREATE)
{ {
CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam; CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam;
ITextHost *texthost;
TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style); TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style);
texthost = ME_CreateTextHost(hWnd, pcs, FALSE); return create_windowed_editor( hWnd, pcs, FALSE );
return texthost != NULL;
} }
else else
{ {
...@@ -4938,12 +4960,10 @@ LRESULT WINAPI RichEdit10ANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM ...@@ -4938,12 +4960,10 @@ LRESULT WINAPI RichEdit10ANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
{ {
if (msg == WM_NCCREATE && !GetWindowLongPtrW(hWnd, 0)) if (msg == WM_NCCREATE && !GetWindowLongPtrW(hWnd, 0))
{ {
ITextHost *texthost;
CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam; CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam;
TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style); TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style);
texthost = ME_CreateTextHost(hWnd, pcs, TRUE); return create_windowed_editor( hWnd, pcs, TRUE );
return texthost != NULL;
} }
return RichEditANSIWndProc(hWnd, msg, wParam, lParam); return RichEditANSIWndProc(hWnd, msg, wParam, lParam);
} }
......
...@@ -45,24 +45,15 @@ static const ITextHostVtbl textHostVtbl; ...@@ -45,24 +45,15 @@ static const ITextHostVtbl textHostVtbl;
ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10) ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10)
{ {
ITextHostImpl *texthost; ITextHostImpl *texthost;
texthost = CoTaskMemAlloc(sizeof(*texthost)); texthost = CoTaskMemAlloc(sizeof(*texthost));
if (texthost) if (!texthost) return NULL;
{
ME_TextEditor *editor;
texthost->ITextHost_iface.lpVtbl = &textHostVtbl; texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
texthost->ref = 1; texthost->ref = 1;
texthost->hWnd = hwnd; texthost->hWnd = hwnd;
texthost->bEmulateVersion10 = bEmulateVersion10; 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);
}
return &texthost->ITextHost_iface; return &texthost->ITextHost_iface;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment