static void release_client_site(WebBrowser *This) { release_dochost_client(&This->doc_host); if(This->shell_embedding_hwnd) { DestroyWindow(This->shell_embedding_hwnd); This->shell_embedding_hwnd = NULL; } if(This->inplace) { IOleInPlaceSite_Release(This->inplace); This->inplace = NULL; } if(This->container) { IOleContainer_Release(This->container); This->container = NULL; } if(This->uiwindow) { IOleInPlaceUIWindow_Release(This->uiwindow); This->uiwindow = NULL; } if(This->client) { IOleClientSite_Release(This->client); This->client = NULL; } }
static HRESULT activate_inplace(WebBrowser *This, IOleClientSite *active_site) { HWND parent_hwnd; HRESULT hres; if(This->inplace) return S_OK; if(!active_site) return E_INVALIDARG; hres = IOleClientSite_QueryInterface(active_site, &IID_IOleInPlaceSite, (void**)&This->inplace); if(FAILED(hres)) { WARN("Could not get IOleInPlaceSite\n"); return hres; } hres = IOleInPlaceSite_CanInPlaceActivate(This->inplace); if(hres != S_OK) { WARN("CanInPlaceActivate returned: %08x\n", hres); IOleInPlaceSite_Release(This->inplace); return E_FAIL; } hres = IOleInPlaceSite_GetWindow(This->inplace, &parent_hwnd); if(SUCCEEDED(hres)) SHSetParentHwnd(This->shell_embedding_hwnd, parent_hwnd); IOleInPlaceSite_OnInPlaceActivate(This->inplace); This->frameinfo.cb = sizeof(OLEINPLACEFRAMEINFO); IOleInPlaceSite_GetWindowContext(This->inplace, &This->doc_host.frame, &This->uiwindow, &This->pos_rect, &This->clip_rect, &This->frameinfo); 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) { IOleContainer *container; IOleClientSite_ShowObject(This->client); hres = IOleClientSite_GetContainer(This->client, &container); if(SUCCEEDED(hres)) { if(This->container) IOleContainer_Release(This->container); This->container = container; } } if(This->doc_host.frame) IOleInPlaceFrame_GetWindow(This->doc_host.frame, &This->frame_hwnd); return S_OK; }
static HRESULT activate_inplace(WindowsMediaPlayer *This) { IOleInPlaceSiteWindowless *ipsite_windowless; IOleInPlaceSiteEx *ipsiteex = NULL; IOleInPlaceSite *ipsite; IOleInPlaceUIWindow *ip_window = NULL; IOleInPlaceFrame *ip_frame = NULL; RECT posrect = {0}, cliprect = {0}; OLEINPLACEFRAMEINFO frameinfo = { sizeof(frameinfo) }; HRESULT hres; if(This->hwnd) { FIXME("Already activated\n"); return E_UNEXPECTED; } hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSiteWindowless, (void**)&ipsite_windowless); if(SUCCEEDED(hres)) { hres = IOleInPlaceSiteWindowless_CanWindowlessActivate(ipsite_windowless); IOleInPlaceSiteWindowless_Release(ipsite_windowless); if(hres == S_OK) FIXME("Windowless activation not supported\n"); ipsiteex = (IOleInPlaceSiteEx*)ipsite_windowless; }else { IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex); } if(ipsiteex) { BOOL redraw = FALSE; /* Not really used. */ IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex, &redraw, 0); ipsite = (IOleInPlaceSite*)ipsiteex; }else { IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSite, (void**)&ipsite); if(FAILED(hres)) { FIXME("No IOleInPlaceSite instance\n"); return hres; } IOleInPlaceSite_OnInPlaceActivate(ipsite); } hres = IOleInPlaceSite_GetWindowContext(ipsite, &ip_frame, &ip_window, &posrect, &cliprect, &frameinfo); IOleInPlaceSite_Release(ipsite); if(FAILED(hres)) { FIXME("GetWindowContext failed: %08x\n", hres); return hres; } This->hwnd = create_wmp_window(This, &posrect); if(!This->hwnd) return E_FAIL; IOleClientSite_ShowObject(This->client_site); return S_OK; }
static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface) { WebBrowser *This = impl_from_IOleInPlaceObject(iface); FIXME("(%p)\n", This); if(This->inplace) { IOleInPlaceSite_Release(This->inplace); This->inplace = NULL; } return S_OK; }
static HRESULT activate_inplace(WebBrowser *This, IOleClientSite *active_site, HWND parent_hwnd) { HRESULT hres; if(This->inplace) return S_OK; if(!active_site) return E_INVALIDARG; hres = IOleClientSite_QueryInterface(active_site, &IID_IOleInPlaceSite, (void**)&This->inplace); if(FAILED(hres)) { WARN("Could not get IOleInPlaceSite\n"); return hres; } hres = IOleInPlaceSite_CanInPlaceActivate(This->inplace); if(hres != S_OK) { WARN("CanInPlaceActivate returned: %08lx\n", hres); IOleInPlaceSite_Release(This->inplace); return E_FAIL; } hres = IOleInPlaceSite_GetWindow(This->inplace, &This->iphwnd); if(FAILED(hres)) This->iphwnd = parent_hwnd; IOleInPlaceSite_OnInPlaceActivate(This->inplace); IOleInPlaceSite_GetWindowContext(This->inplace, &This->frame, &This->uiwindow, &This->pos_rect, &This->clip_rect, &This->frameinfo); 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); } if(This->frame) IOleInPlaceFrame_GetWindow(This->frame, &This->frame_hwnd); return S_OK; }
static void deactivate_window(WindowsMediaPlayer *This) { IOleInPlaceSite *ip_site; HRESULT hres; hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSite, (void**)&ip_site); if(SUCCEEDED(hres)) { IOleInPlaceSite_OnInPlaceDeactivate(ip_site); IOleInPlaceSite_Release(ip_site); } DestroyWindow(This->hwnd); This->hwnd = NULL; }
static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite) { HTMLDocument *This = DOCVIEW_THIS(iface); TRACE("(%p)->(%p)\n", This, pIPSite); if(pIPSite) IOleInPlaceSite_AddRef(pIPSite); if(This->ipsite) IOleInPlaceSite_Release(This->ipsite); This->ipsite = pIPSite; return S_OK; }
static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite) { HTMLDocument *This = impl_from_IOleDocumentView(iface); TRACE("(%p)->(%p)\n", This, pIPSite); if(pIPSite) IOleInPlaceSite_AddRef(pIPSite); if(This->doc_obj->ipsite) IOleInPlaceSite_Release(This->doc_obj->ipsite); This->doc_obj->ipsite = pIPSite; This->doc_obj->request_uiactivate = TRUE; return S_OK; }
static void create_shell_embedding_hwnd(WebBrowser *This) { IOleInPlaceSite *inplace; HWND parent = NULL; HRESULT hres; static const WCHAR wszShellEmbedding[] = {'S','h','e','l','l',' ','E','m','b','e','d','d','i','n','g',0}; if(!shell_embedding_atom) { static WNDCLASSEXW wndclass = { sizeof(wndclass), CS_DBLCLKS, shell_embedding_proc, 0, 0 /* native uses 8 */, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, wszShellEmbedding, NULL }; wndclass.hInstance = shdocvw_hinstance; RegisterClassExW(&wndclass); } hres = IOleClientSite_QueryInterface(This->client, &IID_IOleInPlaceSite, (void**)&inplace); if(SUCCEEDED(hres)) { IOleInPlaceSite_GetWindow(inplace, &parent); IOleInPlaceSite_Release(inplace); } This->doc_host.frame_hwnd = This->shell_embedding_hwnd = CreateWindowExW( WS_EX_WINDOWEDGE, wszShellEmbedding, wszShellEmbedding, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | (parent ? WS_CHILD | WS_TABSTOP : WS_POPUP | WS_MAXIMIZEBOX), 0, 0, 0, 0, parent, NULL, shdocvw_hinstance, This); TRACE("parent=%p hwnd=%p\n", parent, This->shell_embedding_hwnd); }
void ReleaseWebBrowser(HHInfo *info) { WebBrowserContainer *container = info->web_browser; HRESULT hres; if(!container) return; if(container->ole_obj) { IOleInPlaceSite *inplace; hres = IOleObject_QueryInterface(container->ole_obj, &IID_IOleInPlaceSite, (void**)&inplace); if(SUCCEEDED(hres)) { IOleInPlaceSite_OnInPlaceDeactivate(inplace); IOleInPlaceSite_Release(inplace); } IOleObject_SetClientSite(container->ole_obj, NULL); } info->web_browser = NULL; IOleClientSite_Release(&container->IOleClientSite_iface); }
static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite) { WebBrowser *This = OLEOBJ_THIS(iface); IOleContainer *container; HRESULT hres; TRACE("(%p)->(%p)\n", This, pClientSite); if(This->client == pClientSite) return S_OK; if(This->doc_host.hwnd) { DestroyWindow(This->doc_host.hwnd); This->doc_host.hwnd = NULL; } if(This->shell_embedding_hwnd) { DestroyWindow(This->shell_embedding_hwnd); This->shell_embedding_hwnd = NULL; } if(This->inplace) { IOleInPlaceSite_Release(This->inplace); This->inplace = NULL; } if(This->doc_host.hostui) IDocHostUIHandler_Release(This->doc_host.hostui); if(This->client) IOleClientSite_Release(This->client); if(!pClientSite) { if(This->doc_host.document) deactivate_document(&This->doc_host); This->client = NULL; return S_OK; } This->client = pClientSite; IOleClientSite_AddRef(pClientSite); hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler, (void**)&This->doc_host.hostui); if(FAILED(hres)) This->doc_host.hostui = NULL; hres = IOleClientSite_GetContainer(This->client, &container); if(SUCCEEDED(hres)) { ITargetContainer *target_container; hres = IOleContainer_QueryInterface(container, &IID_ITargetContainer, (void**)&target_container); if(SUCCEEDED(hres)) { FIXME("Unsupported ITargetContainer\n"); ITargetContainer_Release(target_container); } IOleContainer_Release(container); } create_shell_embedding_hwnd(This); return S_OK; }
static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite) { WebBrowser *This = impl_from_IOleObject(iface); IDocHostUIHandler *hostui; IOleCommandTarget *olecmd; BOOL get_olecmd = TRUE; IOleContainer *container; IDispatch *disp; HRESULT hres; TRACE("(%p)->(%p)\n", This, pClientSite); if(This->client_closed) { IOleClientSite_Release(This->client_closed); This->client_closed = NULL; } if(This->client == pClientSite) return S_OK; if(This->client && pClientSite) { get_olecmd = FALSE; olecmd = This->doc_host.olecmd; if(olecmd) IOleCommandTarget_AddRef(olecmd); } release_client_site(This, !pClientSite); if(!pClientSite) { on_commandstate_change(&This->doc_host, CSC_NAVIGATEBACK, FALSE); on_commandstate_change(&This->doc_host, CSC_NAVIGATEFORWARD, FALSE); if(This->doc_host.document) deactivate_document(&This->doc_host); return S_OK; } IOleClientSite_AddRef(pClientSite); This->client = pClientSite; hres = IOleClientSite_QueryInterface(This->client, &IID_IDispatch, (void**)&disp); if(SUCCEEDED(hres)) This->doc_host.client_disp = disp; hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler, (void**)&hostui); if(SUCCEEDED(hres)) This->doc_host.hostui = hostui; if(get_olecmd) { hres = IOleClientSite_GetContainer(This->client, &container); if(SUCCEEDED(hres)) { ITargetContainer *target_container; hres = IOleContainer_QueryInterface(container, &IID_ITargetContainer, (void**)&target_container); if(SUCCEEDED(hres)) { FIXME("Unsupported ITargetContainer\n"); ITargetContainer_Release(target_container); } hres = IOleContainer_QueryInterface(container, &IID_IOleCommandTarget, (void**)&olecmd); if(FAILED(hres)) olecmd = NULL; IOleContainer_Release(container); }else { hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&olecmd); if(FAILED(hres)) olecmd = NULL; } } This->doc_host.olecmd = olecmd; if(This->shell_embedding_hwnd) { IOleInPlaceSite *inplace; HWND parent; hres = IOleClientSite_QueryInterface(This->client, &IID_IOleInPlaceSite, (void**)&inplace); if(SUCCEEDED(hres)) { hres = IOleInPlaceSite_GetWindow(inplace, &parent); IOleInPlaceSite_Release(inplace); if(SUCCEEDED(hres)) SHSetParentHwnd(This->shell_embedding_hwnd, parent); } }else { create_shell_embedding_hwnd(This); } on_offlineconnected_change(This); on_silent_change(This); return S_OK; }