static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) { WebBrowser *This = impl_from_IWebBrowser2(iface); IOleCommandTarget *target = NULL; HRESULT hres; TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut); if(This->container) { hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target); if(FAILED(hres)) target = NULL; } if(!target && This->doc_host.document) { hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target); if(FAILED(hres)) target = NULL; } if(!target) return E_UNEXPECTED; hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut); IOleCommandTarget_Release(target); return hres; }
static HRESULT DocHostContainer_exec(DocHost *doc_host, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in, VARIANT *out) { WebBrowser *This = impl_from_DocHost(doc_host); IOleCommandTarget *cmdtrg = NULL; HRESULT hres; if(This->client) { hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg); if(FAILED(hres)) cmdtrg = NULL; } if(!cmdtrg && This->container) { hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (void**)&cmdtrg); if(FAILED(hres)) cmdtrg = NULL; } if(!cmdtrg) return E_NOTIMPL; hres = IOleCommandTarget_Exec(cmdtrg, cmd_group, cmdid, execopt, in, out); IOleCommandTarget_Release(cmdtrg); if(SUCCEEDED(hres)) TRACE("Exec returned %08x %s\n", hres, debugstr_variant(out)); else FIXME("Exec failed\n"); return hres; }
static HWND get_container_hwnd(WindowsMediaPlayer *This) { IOleWindow *ole_window; HWND hwnd = NULL; HRESULT hres; /* IOleInPlaceSite (which inherits from IOleWindow) is preferred. */ hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSite, (void**)&ole_window); if(FAILED(hres)) { hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleWindow, (void**)&ole_window); if(FAILED(hres)) { IOleContainer *container = NULL; hres = IOleClientSite_GetContainer(This->client_site, &container); if(SUCCEEDED(hres)) { hres = IOleContainer_QueryInterface(container, &IID_IOleWindow, (void**)&ole_window); IOleContainer_Release(container); } } } if(FAILED(hres)) return NULL; hres = IOleWindow_GetWindow(ole_window, &hwnd); IOleWindow_Release(ole_window); if(FAILED(hres)) return NULL; TRACE("Got window %p\n", hwnd); return hwnd; }
static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite) { WebBrowser *This = impl_from_IOleObject(iface); IDocHostUIHandler *hostui; IOleContainer *container; IDispatch *disp; HRESULT hres; TRACE("(%p)->(%p)\n", This, pClientSite); if(This->client == pClientSite) return S_OK; release_client_site(This); if(!pClientSite) { 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; 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); on_offlineconnected_change(This); on_silent_change(This); return S_OK; }
static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf) { WebBrowser *This = impl_from_IWebBrowser2(iface); IOleCommandTarget *target = NULL; OLECMD ole_command[1]; HRESULT hres; TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf); if (!pcmdf) return E_POINTER; ole_command[0].cmdID = cmdID; ole_command[0].cmdf = *pcmdf; if (This->container) { hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target); if(FAILED(hres)) target = NULL; } if (!target && This->doc_host.document) { hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target); if(FAILED(hres)) target = NULL; } if (!target) return E_UNEXPECTED; hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL); if (SUCCEEDED(hres)) *pcmdf = ole_command[0].cmdf; if (hres == OLECMDERR_E_NOTSUPPORTED) { *pcmdf = 0; hres = S_OK; } IOleCommandTarget_Release(target); return hres; }
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; }