rendered paste bodyFrom 745a532eeeeb695befb548583e4d11d46cfdaa2f Mon Sep 17 00:00:00 2001From: Austin Lund <austin.lund@gmail.com>Date: Tue, 6 Jul 2010 12:24:32 +1000Subject: [PATCH] riched20: Make sure that an editor is present.--- dlls/riched20/editor.c | 22 ++++++---------------- dlls/riched20/editor.h | 2 +- dlls/riched20/txthost.c | 4 ++-- 3 files changed, 9 insertions(+), 19 deletions(-)diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.cindex b4bff4f..693f5b1 100644--- a/dlls/riched20/editor.c+++ b/dlls/riched20/editor.c@@ -4397,20 +4397,11 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, editor = (ME_TextEditor *)GetWindowLongPtrW(hWnd, 0); if (!editor) {- if (msg == WM_NCCREATE)- {- CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam;- ITextHost *texthost;+ ITextHost *texthost; - TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style);- texthost = ME_CreateTextHost(hWnd, pcs, FALSE);- return texthost != NULL;- }- else if (msg != WM_NCDESTROY)- {- ERR("called with invalid hWnd %p - application bug?\n", hWnd);- return 0;- }+ TRACE("No TextEditor. Creating one.\n");+ texthost = ME_CreateTextHost(hWnd, FALSE);+ return texthost != NULL; } switch (msg)@@ -4530,10 +4521,9 @@ 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);+ TRACE("No TextEditor. Creating one.\n");+ texthost = ME_CreateTextHost(hWnd, TRUE); return texthost != NULL; } return RichEditANSIWndProc(hWnd, msg, wParam, lParam);diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.hindex 9739eea..f274a9b 100644--- a/dlls/riched20/editor.h+++ b/dlls/riched20/editor.h@@ -270,7 +270,7 @@ struct RTFTable *ME_MakeTableDef(ME_TextEditor *editor); void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef); /* txthost.c */-ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10);+ITextHost *ME_CreateTextHost(HWND hwnd, BOOL bEmulateVersion10); #ifdef __i386__ /* Use wrappers to perform thiscall on i386 */ #define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl) #else /* __i386__ */diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.cindex 68f4437..4de1e06 100644--- a/dlls/riched20/txthost.c+++ b/dlls/riched20/txthost.c@@ -44,7 +44,7 @@ typedef struct ITextHostImpl { static const ITextHostVtbl textHostVtbl; -ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10)+ITextHost *ME_CreateTextHost(HWND hwnd, BOOL bEmulateVersion10) { ITextHostImpl *texthost; texthost = CoTaskMemAlloc(sizeof(*texthost));@@ -61,7 +61,7 @@ ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion1 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;+ editor->hwndParent = (HWND)GetWindowLongW(hwnd, GWLP_HWNDPARENT); SetWindowLongPtrW(hwnd, 0, (LONG_PTR)editor); } -- 1.7.0.4