static void IOCS_OnSize( IOCS* This, LPCRECT rect ) { SIZEL inPix, inHi; This->size.left = rect->left; This->size.right = rect->right; This->size.top = rect->top; This->size.bottom = rect->bottom; if ( !This->control ) return; inPix.cx = rect->right - rect->left; inPix.cy = rect->bottom - rect->top; AtlPixelToHiMetric( &inPix, &inHi ); IOleObject_SetExtent( This->control, DVASPECT_CONTENT, &inHi ); if ( This->fInPlace ) { IOleInPlaceObject *wl; if ( SUCCEEDED( IOleObject_QueryInterface( This->control, &IID_IOleInPlaceObject, (void**)&wl ) ) ) { IOleInPlaceObject_SetObjectRects( wl, rect, rect ); IOleInPlaceObject_Release( wl ); } } }
static HRESULT WINAPI PHInPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface) { PluginHost *This = impl_from_IOleInPlaceSiteEx(iface); TRACE("(%p)\n", This); if(This->ip_object) { IOleInPlaceObject_Release(This->ip_object); This->ip_object = NULL; } return S_OK; }
static HRESULT STDMETHODCALLTYPE InPlace_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect) { WebBrowserContainer *This = impl_from_IOleInPlaceSite(iface); IOleInPlaceObject *inplace; if (IOleObject_QueryInterface(This->ole_obj, &IID_IOleInPlaceObject, (void **)&inplace) == S_OK) { IOleInPlaceObject_SetObjectRects(inplace, lprcPosRect, lprcPosRect); IOleInPlaceObject_Release(inplace); } return S_OK; }
BOOL InitWebBrowser(HHInfo *info, HWND hwndParent) { WebBrowserContainer *container; IOleInPlaceObject *inplace; HRESULT hr; RECT rc; container = heap_alloc_zero(sizeof(*container)); if (!container) return FALSE; container->IOleClientSite_iface.lpVtbl = &OleClientSiteVtbl; container->IOleInPlaceSite_iface.lpVtbl = &OleInPlaceSiteVtbl; container->IOleInPlaceFrame_iface.lpVtbl = &OleInPlaceFrameVtbl; container->IDocHostUIHandler_iface.lpVtbl = &DocHostUIHandlerVtbl; container->ref = 1; container->hwndWindow = hwndParent; info->web_browser = container; hr = OleCreate(&CLSID_WebBrowser, &IID_IOleObject, OLERENDER_DRAW, 0, &container->IOleClientSite_iface, &MyIStorage, (void **)&container->ole_obj); if (FAILED(hr)) goto error; GetClientRect(hwndParent, &rc); hr = OleSetContainedObject((struct IUnknown *)container->ole_obj, TRUE); if (FAILED(hr)) goto error; hr = IOleObject_DoVerb(container->ole_obj, OLEIVERB_SHOW, NULL, &container->IOleClientSite_iface, -1, hwndParent, &rc); if (FAILED(hr)) goto error; hr = IOleObject_QueryInterface(container->ole_obj, &IID_IOleInPlaceObject, (void**)&inplace); if (FAILED(hr)) goto error; IOleInPlaceObject_SetObjectRects(inplace, &rc, &rc); IOleInPlaceObject_Release(inplace); hr = IOleObject_QueryInterface(container->ole_obj, &IID_IWebBrowser2, (void **)&container->web_browser); if (SUCCEEDED(hr)) return TRUE; error: ReleaseWebBrowser(info); return FALSE; }
static ULONG WINAPI PHClientSite_Release(IOleClientSite *iface) { PluginHost *This = impl_from_IOleClientSite(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); if(!ref) { if(This->disp) IDispatch_Release(This->disp); if(This->ip_object) IOleInPlaceObject_Release(This->ip_object); list_remove(&This->entry); if(This->element) This->element->plugin_host = NULL; if(This->plugin_unk) IUnknown_Release(This->plugin_unk); heap_free(This); } return ref; }
static void test_wmp(void) { IProvideClassInfo2 *class_info; IOleClientSite *client_site; IOleInPlaceObject *ipobj; IPersistStreamInit *psi; IOleObject *oleobj; IWMPCore *wmpcore; DWORD misc_status; RECT pos = {0,0,100,100}; HWND hwnd; GUID guid; LONG ref; HRESULT hres; BSTR str; hres = CoCreateInstance(&CLSID_WindowsMediaPlayer, NULL, CLSCTX_INPROC_SERVER, &IID_IOleObject, (void**)&oleobj); if(hres == REGDB_E_CLASSNOTREG) { win_skip("CLSID_WindowsMediaPlayer not registered\n"); return; } ok(hres == S_OK, "Could not create CLSID_WindowsMediaPlayer instance: %08x\n", hres); hres = IOleObject_QueryInterface(oleobj, &IID_IWMPCore, (void**)&wmpcore); ok(hres == S_OK, "got 0x%08x\n", hres); hres = IWMPCore_get_versionInfo(wmpcore, NULL); ok(hres == E_POINTER, "got 0x%08x\n", hres); hres = IWMPCore_get_versionInfo(wmpcore, &str); ok(hres == S_OK, "got 0x%08x\n", hres); SysFreeString(str); IWMPCore_Release(wmpcore); hres = IOleObject_QueryInterface(oleobj, &IID_IProvideClassInfo2, (void**)&class_info); ok(hres == S_OK, "Could not get IProvideClassInfo2 iface: %08x\n", hres); hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid); ok(hres == S_OK, "GetGUID failed: %08x\n", hres); ok(IsEqualGUID(&guid, &IID__WMPOCXEvents), "guid = %s\n", wine_dbgstr_guid(&guid)); IProvideClassInfo2_Release(class_info); test_QI((IUnknown*)oleobj); hres = IOleObject_GetMiscStatus(oleobj, DVASPECT_CONTENT, &misc_status); ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres); ok(misc_status == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE), "misc_status = %x\n", misc_status); hres = IOleObject_QueryInterface(oleobj, &IID_IPersistStreamInit, (void**)&psi); ok(hres == S_OK, "Could not get IPersistStreamInit iface: %08x\n", hres); hres = IOleObject_QueryInterface(oleobj, &IID_IOleInPlaceObject, (void**)&ipobj); ok(hres == S_OK, "Could not get IOleInPlaceObject iface: %08x\n", hres); hres = IPersistStreamInit_InitNew(psi); ok(hres == E_FAIL || broken(hres == S_OK /* Old WMP */), "InitNew failed: %08x\n", hres); SET_EXPECT(GetContainer); SET_EXPECT(GetExtendedControl); SET_EXPECT(GetWindow); SET_EXPECT(Invoke_USERMODE); hres = IOleObject_SetClientSite(oleobj, &ClientSite); ok(hres == S_OK, "SetClientSite failed: %08x\n", hres); todo_wine CHECK_CALLED(GetContainer); CHECK_CALLED(GetExtendedControl); todo_wine CHECK_CALLED(GetWindow); todo_wine CHECK_CALLED(Invoke_USERMODE); client_site = NULL; hres = IOleObject_GetClientSite(oleobj, &client_site); ok(hres == S_OK, "GetClientSite failed: %08x\n", hres); ok(client_site == &ClientSite, "client_site != ClientSite\n"); SET_EXPECT(GetWindow); hres = IPersistStreamInit_InitNew(psi); ok(hres == S_OK, "InitNew failed: %08x\n", hres); CHECK_CALLED(GetWindow); hwnd = (HWND)0xdeadbeef; hres = IOleInPlaceObject_GetWindow(ipobj, &hwnd); ok(hres == E_UNEXPECTED, "GetWindow failed: %08x\n", hres); ok(!hwnd, "hwnd = %p\n", hwnd); SET_EXPECT(GetWindow); SET_EXPECT(CanWindowlessActivate); SET_EXPECT(OnInPlaceActivateEx); SET_EXPECT(GetWindowContext); SET_EXPECT(ShowObject); hres = IOleObject_DoVerb(oleobj, OLEIVERB_INPLACEACTIVATE, NULL, &ClientSite, 0, container_hwnd, &pos); ok(hres == S_OK, "DoVerb failed: %08x\n", hres); CHECK_CALLED(GetWindow); CHECK_CALLED(CanWindowlessActivate); CHECK_CALLED(OnInPlaceActivateEx); CHECK_CALLED(GetWindowContext); CHECK_CALLED(ShowObject); hwnd = NULL; hres = IOleInPlaceObject_GetWindow(ipobj, &hwnd); ok(hres == S_OK, "GetWindow failed: %08x\n", hres); ok(hwnd != NULL, "hwnd = NULL\n"); test_window(hwnd); SetRect(&pos, 1, 2, 301, 312); hres = IOleInPlaceObject_SetObjectRects(ipobj, &pos, &pos); ok(hres == S_OK, "SetObjectRects failed: %08x\n", hres); GetClientRect(hwnd, &pos); test_rect_size(&pos, 300, 310); test_wmp_ifaces(oleobj); hres = IOleObject_DoVerb(oleobj, OLEIVERB_HIDE, NULL, &ClientSite, 0, container_hwnd, &pos); ok(hres == S_OK, "DoVerb failed: %08x\n", hres); ok(!IsWindowVisible(hwnd), "Window is visible\n"); SET_EXPECT(OnShowWindow_FALSE); SET_EXPECT(OnInPlaceDeactivate); hres = IOleObject_Close(oleobj, 0); ok(hres == S_OK, "Close failed: %08x\n", hres); todo_wine CHECK_CALLED(OnShowWindow_FALSE); CHECK_CALLED(OnInPlaceDeactivate); hwnd = (HWND)0xdeadbeef; hres = IOleInPlaceObject_GetWindow(ipobj, &hwnd); ok(hres == E_UNEXPECTED, "GetWindow failed: %08x\n", hres); ok(!hwnd, "hwnd = %p\n", hwnd); hres = IOleObject_Close(oleobj, 0); ok(hres == S_OK, "Close failed: %08x\n", hres); hres = IOleObject_SetClientSite(oleobj, NULL); ok(hres == S_OK, "SetClientSite failed: %08x\n", hres); client_site = (void*)0xdeadbeef; hres = IOleObject_GetClientSite(oleobj, &client_site); ok(hres == E_FAIL || broken(hres == S_OK), "GetClientSite failed: %08x\n", hres); ok(!client_site, "client_site = %p\n", client_site); IPersistStreamInit_Release(psi); IOleInPlaceObject_Release(ipobj); ref = IOleObject_Release(oleobj); ok(!ref, "ref = %d\n", ref); }