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 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 = IOleInPlaceSiteEx_CanInPlaceActivate(This->inplace); if(hres != S_OK) { WARN("CanInPlaceActivate returned: %08x\n", hres); IOleInPlaceSiteEx_Release(This->inplace); This->inplace = NULL; return E_FAIL; } hres = IOleInPlaceSiteEx_GetWindow(This->inplace, &parent_hwnd); if(SUCCEEDED(hres)) SHSetParentHwnd(This->shell_embedding_hwnd, parent_hwnd); IOleInPlaceSiteEx_OnInPlaceActivate(This->inplace); This->frameinfo.cb = sizeof(OLEINPLACEFRAMEINFO); IOleInPlaceSiteEx_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; }