From 8be6eb25bd0d48443780ee7427ddf83c2c133017 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 28 Nov 2005 11:17:28 +0100 Subject: [PATCH] Better windows handling. --- dlls/shdocvw/dochost.c | 52 +++++++++++++++++++++++++++++++++++++++ dlls/shdocvw/oleobject.c | 45 +++++++-------------------------- dlls/shdocvw/shdocvw.h | 2 ++ dlls/shdocvw/webbrowser.c | 3 +++ 4 files changed, 66 insertions(+), 36 deletions(-) diff --git a/dlls/shdocvw/dochost.c b/dlls/shdocvw/dochost.c index c8ef021edaf..0e7628f1a62 100644 --- a/dlls/shdocvw/dochost.c +++ b/dlls/shdocvw/dochost.c @@ -21,6 +21,56 @@ WINE_DEFAULT_DEBUG_CHANNEL(shdocvw); +static ATOM doc_view_atom = 0; + +static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + WebBrowser *This; + + static const WCHAR wszTHIS[] = {'T','H','I','S',0}; + + if(msg == WM_CREATE) { + This = *(WebBrowser**)lParam; + ERR("create %p\n", This); + SetPropW(hwnd, wszTHIS, This); + }else { + This = GetPropW(hwnd, wszTHIS); + } + + return DefWindowProcA(hwnd, msg, wParam, lParam); +} + +void create_doc_view_hwnd(WebBrowser *This) +{ + RECT rect; + + static const WCHAR wszShell_DocObject_View[] = + {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0}; + + if(!doc_view_atom) { + static WNDCLASSEXW wndclass = { + sizeof(wndclass), + CS_PARENTDC, + doc_view_proc, + 0, 0 /* native uses 4*/, NULL, NULL, NULL, + (HBRUSH)COLOR_WINDOWFRAME, NULL, + wszShell_DocObject_View, + NULL + }; + + wndclass.hInstance = shdocvw_hinstance; + + doc_view_atom = RegisterClassExW(&wndclass); + } + + GetWindowRect(This->shell_embedding_hwnd, &rect); + This->doc_view_hwnd = CreateWindowExW(0, wszShell_DocObject_View, + wszShell_DocObject_View, + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX, + rect.left, rect.top, rect.right, rect.bottom, This->shell_embedding_hwnd, + NULL, shdocvw_hinstance, This); +} + #define DOCHOSTUI_THIS(iface) DEFINE_THIS(WebBrowser, DocHostUIHandler, iface) static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, @@ -214,4 +264,6 @@ static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl = { void WebBrowser_DocHost_Init(WebBrowser *This) { This->lpDocHostUIHandlerVtbl = &DocHostUIHandler2Vtbl; + + This->doc_view_hwnd = NULL; } diff --git a/dlls/shdocvw/oleobject.c b/dlls/shdocvw/oleobject.c index f0dbeb39ed5..77ff56ee613 100644 --- a/dlls/shdocvw/oleobject.c +++ b/dlls/shdocvw/oleobject.c @@ -29,46 +29,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(shdocvw); -static ATOM doc_view_atom = 0; static ATOM shell_embedding_atom = 0; -static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - return DefWindowProcA(hwnd, msg, wParam, lParam); -} - static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { return DefWindowProcA(hwnd, msg, wParam, lParam); } -static void create_doc_view_hwnd(WebBrowser *This) -{ - static const WCHAR wszShell_DocObject_View[] = - {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0}; - - if(!doc_view_atom) { - static WNDCLASSEXW wndclass = { - sizeof(wndclass), - CS_PARENTDC, - doc_view_proc, - 0, 0 /* native uses 4*/, NULL, NULL, NULL, - (HBRUSH)COLOR_WINDOWFRAME, NULL, - wszShell_DocObject_View, - NULL - }; - - wndclass.hInstance = shdocvw_hinstance; - - doc_view_atom = RegisterClassExW(&wndclass); - } - - This->doc_view_hwnd = CreateWindowExW(0, wszShell_DocObject_View, NULL, - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX, - 0, 0, 0, 0, This->shell_embedding_hwnd, - NULL, shdocvw_hinstance, This); -} - static void create_shell_embedding_hwnd(WebBrowser *This) { IOleInPlaceSite *inplace; @@ -99,12 +66,10 @@ static void create_shell_embedding_hwnd(WebBrowser *This) IOleInPlaceSite_Release(inplace); } - This->shell_embedding_hwnd = CreateWindowExW(0, wszShellEmbedding, NULL, + This->shell_embedding_hwnd = CreateWindowExW(0, wszShellEmbedding, wszShellEmbedding, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX, 0, 0, 0, 0, parent, NULL, shdocvw_hinstance, This); - - create_doc_view_hwnd(This); } /********************************************************************** @@ -266,6 +231,13 @@ static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tag IOleInPlaceSite_Release(inplace); + SetWindowPos(This->shell_embedding_hwnd, NULL, + This->pos_rect.left, This->pos_rect.top, + This->pos_rect.right-This->pos_rect.left, + This->pos_rect.bottom-This->pos_rect.top, + SWP_NOZORDER | SWP_SHOWWINDOW); + + if(This->client) { IOleClientSite_ShowObject(This->client); IOleClientSite_GetContainer(This->client, &This->container); @@ -586,6 +558,7 @@ void WebBrowser_OleObject_Init(WebBrowser *This) This->frame_hwnd = NULL; This->frame = NULL; This->uiwindow = NULL; + This->shell_embedding_hwnd = NULL; memset(&This->pos_rect, 0, sizeof(RECT)); memset(&This->clip_rect, 0, sizeof(RECT)); diff --git a/dlls/shdocvw/shdocvw.h b/dlls/shdocvw/shdocvw.h index 128e75c321f..f38aaeadbd8 100644 --- a/dlls/shdocvw/shdocvw.h +++ b/dlls/shdocvw/shdocvw.h @@ -146,6 +146,8 @@ void WebBrowser_Events_Destroy(WebBrowser*); HRESULT WebBrowser_Create(IUnknown*,REFIID,void**); +void create_doc_view_hwnd(WebBrowser *This); + #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl))) /********************************************************************** diff --git a/dlls/shdocvw/webbrowser.c b/dlls/shdocvw/webbrowser.c index 79a773991de..63bc5c868df 100644 --- a/dlls/shdocvw/webbrowser.c +++ b/dlls/shdocvw/webbrowser.c @@ -515,6 +515,9 @@ static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VA if(V_VT(URL) != VT_BSTR) return E_INVALIDARG; + if(!This->doc_view_hwnd) + create_doc_view_hwnd(This); + /* * FIXME: * We should use URLMoniker's BindToObject instead creating HTMLDocument here.