/****************************************************************** * CreateTextServices (RICHED20.4) */ HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, IUnknown **ppUnk) { ITextServicesImpl *ITextImpl; TRACE("%p %p --> %p\n", pUnkOuter, pITextHost, ppUnk); if (pITextHost == NULL) return E_POINTER; ITextImpl = CoTaskMemAlloc(sizeof(*ITextImpl)); if (ITextImpl == NULL) return E_OUTOFMEMORY; InitializeCriticalSection(&ITextImpl->csTxtSrv); ITextImpl->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv"); ITextImpl->ref = 1; ITextHost_AddRef(pITextHost); ITextImpl->pMyHost = pITextHost; ITextImpl->IUnknown_inner.lpVtbl = &textservices_inner_vtbl; ITextImpl->ITextServices_iface.lpVtbl = &textservices_vtbl; ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE, ES_LEFT); ITextImpl->editor->exStyleFlags = 0; ITextImpl->editor->rcFormat.left = 0; ITextImpl->editor->rcFormat.top = 0; ITextImpl->editor->rcFormat.right = 0; ITextImpl->editor->rcFormat.bottom = 0; if (pUnkOuter) ITextImpl->outer_unk = pUnkOuter; else ITextImpl->outer_unk = &ITextImpl->IUnknown_inner; *ppUnk = &ITextImpl->IUnknown_inner; return S_OK; }
/****************************************************************** * CreateTextServices (RICHED20.4) */ HRESULT WINAPI CreateTextServices(IUnknown * pUnkOuter, ITextHost * pITextHost, IUnknown **ppUnk) { ITextServicesImpl *ITextImpl; HRESULT hres; TRACE("%p %p --> %p\n", pUnkOuter, pITextHost, ppUnk); if (pITextHost == NULL) return E_POINTER; ITextImpl = CoTaskMemAlloc(sizeof(*ITextImpl)); if (ITextImpl == NULL) return E_OUTOFMEMORY; InitializeCriticalSection(&ITextImpl->csTxtSrv); ITextImpl->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv"); ITextImpl->ref = 1; ITextHost_AddRef(pITextHost); ITextImpl->pMyHost = pITextHost; ITextImpl->lpVtbl = &textservices_Vtbl; ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE); ITextImpl->editor->exStyleFlags = 0; ITextImpl->editor->rcFormat = (RECT) { 0,0,0,0 }; ME_HandleMessage(ITextImpl->editor, WM_CREATE, 0, 0, TRUE, &hres); if (pUnkOuter) { FIXME("Support aggregation\n"); return CLASS_E_NOAGGREGATION; } *ppUnk = (IUnknown *)ITextImpl; return S_OK; }
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); 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; }