From a34eaa3c21bccea8043e757d90f8acba0e353b52 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 16 Nov 2005 11:46:56 +0000 Subject: [PATCH] Added OLEIVERB_INPLACEACTIVATE implementation in IOleObject::DoVerb. --- dlls/shdocvw/oleobject.c | 76 +++++++++++++++++++++++++++++++++++---- dlls/shdocvw/shdocvw.h | 13 +++++++ dlls/shdocvw/webbrowser.c | 5 ++- 3 files changed, 85 insertions(+), 9 deletions(-) diff --git a/dlls/shdocvw/oleobject.c b/dlls/shdocvw/oleobject.c index 8fb4a48ceef..240c4d09554 100644 --- a/dlls/shdocvw/oleobject.c +++ b/dlls/shdocvw/oleobject.c @@ -138,15 +138,58 @@ static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tag LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect) { WebBrowser *This = OLEOBJ_THIS(iface); - FIXME("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, + HRESULT hres; + + TRACE("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect); + switch (iVerb) { - case OLEIVERB_INPLACEACTIVATE: - FIXME ("stub for OLEIVERB_INPLACEACTIVATE\n"); - break; - case OLEIVERB_HIDE: - FIXME ("stub for OLEIVERB_HIDE\n"); + case OLEIVERB_INPLACEACTIVATE: { + IOleInPlaceSite *inplace; + + TRACE("OLEIVERB_INPLACEACTIVATE\n"); + + if(!pActiveSite) + return E_INVALIDARG; + + hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleInPlaceSite, (void**)&inplace); + if(FAILED(hres)) { + WARN("Could not get IOleInPlaceSite\n"); + return hres; + } + + hres = IOleInPlaceSite_CanInPlaceActivate(inplace); + if(hres != S_OK) { + WARN("CanInPlaceActivate returned: %08lx\n", hres); + IOleInPlaceSite_Release(inplace); + return E_FAIL; + } + + hres = IOleInPlaceSite_GetWindow(inplace, &This->iphwnd); + if(FAILED(hres)) + This->iphwnd = hwndParent; + + IOleInPlaceSite_OnInPlaceActivate(inplace); + + IOleInPlaceSite_GetWindowContext(inplace, &This->frame, &This->uiwindow, + &This->pos_rect, &This->clip_rect, + &This->frameinfo); + + IOleInPlaceSite_Release(inplace); + + if(This->client) { + IOleClientSite_ShowObject(This->client); + IOleClientSite_GetContainer(This->client, &This->container); + } + + if(This->frame) + IOleInPlaceFrame_GetWindow(This->frame, &This->frame_hwnd); + + return S_OK; + } + default: + FIXME("stub for %ld\n", iVerb); break; } @@ -450,4 +493,25 @@ void WebBrowser_OleObject_Init(WebBrowser *This) This->lpOleControlVtbl = &OleControlVtbl; This->client = NULL; + This->container = NULL; + This->iphwnd = NULL; + This->frame_hwnd = NULL; + This->frame = NULL; + This->uiwindow = NULL; + + memset(&This->pos_rect, 0, sizeof(RECT)); + memset(&This->clip_rect, 0, sizeof(RECT)); + memset(&This->frameinfo, 0, sizeof(OLEINPLACEFRAMEINFO)); +} + +void WebBrowser_OleObject_Destroy(WebBrowser *This) +{ + if(This->client) + IOleClientSite_Release(This->client); + if(This->container) + IOleContainer_Release(This->container); + if(This->frame) + IOleInPlaceFrame_Release(This->frame); + if(This->uiwindow) + IOleInPlaceUIWindow_Release(This->uiwindow); } diff --git a/dlls/shdocvw/shdocvw.h b/dlls/shdocvw/shdocvw.h index f5e01a596f6..f30fa7dd4ca 100644 --- a/dlls/shdocvw/shdocvw.h +++ b/dlls/shdocvw/shdocvw.h @@ -81,6 +81,17 @@ typedef struct { IUnknown *document; IOleClientSite *client; + IOleContainer *container; + + /* window context */ + + HWND iphwnd; + HWND frame_hwnd; + IOleInPlaceFrame *frame; + IOleInPlaceUIWindow *uiwindow; + RECT pos_rect; + RECT clip_rect; + OLEINPLACEFRAMEINFO frameinfo; } WebBrowser; #define WEBBROWSER(x) ((IWebBrowser*) &(x)->lpWebBrowser2Vtbl) @@ -108,6 +119,8 @@ void WebBrowser_Events_Init(WebBrowser*); void WebBrowser_ClientSite_Init(WebBrowser*); +void WebBrowser_OleObject_Destroy(WebBrowser*); + HRESULT WebBrowser_Create(IUnknown*,REFIID,void**); /********************************************************************** diff --git a/dlls/shdocvw/webbrowser.c b/dlls/shdocvw/webbrowser.c index 8e81e497804..a647ae45710 100644 --- a/dlls/shdocvw/webbrowser.c +++ b/dlls/shdocvw/webbrowser.c @@ -121,12 +121,11 @@ static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface) TRACE("(%p) ref=%ld\n", This, ref); if(!ref) { - if(This->client) - IOleClientSite_Release(This->client); - if(This->document) IUnknown_Release(This->document); + WebBrowser_OleObject_Destroy(This); + HeapFree(GetProcessHeap(), 0, This); SHDOCVW_UnlockModule(); }