static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption) { WebBrowser *This = impl_from_IOleObject(iface); IOleClientSite *client; HRESULT hres; TRACE("(%p)->(%d)\n", This, dwSaveOption); if(dwSaveOption != OLECLOSE_NOSAVE) { FIXME("unimplemented flag: %x\n", dwSaveOption); return E_NOTIMPL; } if(This->doc_host.frame) IOleInPlaceFrame_SetActiveObject(This->doc_host.frame, NULL, NULL); if(This->uiwindow) IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, NULL, NULL); if(This->inplace) IOleInPlaceSiteEx_OnUIDeactivate(This->inplace, FALSE); notify_on_focus(This, FALSE); if(This->inplace) IOleInPlaceSiteEx_OnInPlaceDeactivate(This->inplace); /* store old client site - we need to restore it in DoVerb */ client = This->client; if(This->client) IOleClientSite_AddRef(This->client); hres = IOleObject_SetClientSite(iface, NULL); This->client_closed = client; return hres; }
void deactivate_document(DocHost *This) { IOleInPlaceObjectWindowless *winobj; IOleObject *oleobj = NULL; IHlinkTarget *hlink = NULL; HRESULT hres; if(This->doc_navigate) { IUnknown_Release(This->doc_navigate); This->doc_navigate = NULL; } if(This->is_prop_notif) advise_prop_notif(This, FALSE); if(This->view) IOleDocumentView_UIActivate(This->view, FALSE); hres = IUnknown_QueryInterface(This->document, &IID_IOleInPlaceObjectWindowless, (void**)&winobj); if(SUCCEEDED(hres)) { IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj); IOleInPlaceObjectWindowless_Release(winobj); } if(This->view) { IOleDocumentView_Show(This->view, FALSE); IOleDocumentView_CloseView(This->view, 0); IOleDocumentView_SetInPlaceSite(This->view, NULL); IOleDocumentView_Release(This->view); This->view = NULL; } hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj); if(SUCCEEDED(hres)) IOleObject_Close(oleobj, OLECLOSE_NOSAVE); hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink); if(SUCCEEDED(hres)) { IHlinkTarget_SetBrowseContext(hlink, NULL); IHlinkTarget_Release(hlink); } if(oleobj) { IOleClientSite *client_site = NULL; IOleObject_GetClientSite(oleobj, &client_site); if(client_site) { if(client_site == &This->IOleClientSite_iface) IOleObject_SetClientSite(oleobj, NULL); IOleClientSite_Release(client_site); } IOleObject_Release(oleobj); } IUnknown_Release(This->document); This->document = NULL; }
static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable, IMoniker *pimkName, LPBC pibc, DWORD grfMode) { HTMLDocument *This = impl_from_IPersistMoniker(iface); IMoniker *mon; HRESULT hres; TRACE("(%p)->(%x %p %p %08x)\n", This, fFullyAvailable, pimkName, pibc, grfMode); if(pibc) { IUnknown *unk = NULL; /* FIXME: * Use params: * "__PrecreatedObject" * "BIND_CONTEXT_PARAM" * "__HTMLLOADOPTIONS" * "__DWNBINDINFO" * "URL Context" * "_ITransData_Object_" * "_EnumFORMATETC_" */ hres = IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk); if(SUCCEEDED(hres) && unk) { IOleClientSite *client = NULL; hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client); if(SUCCEEDED(hres)) { TRACE("Got client site %p\n", client); IOleObject_SetClientSite(&This->IOleObject_iface, client); IOleClientSite_Release(client); } IUnknown_Release(unk); } } if(This->doc_obj->is_mhtml) { IUnknown *unk; hres = MimeOleObjectFromMoniker(0, pimkName, pibc, &IID_IUnknown, (void**)&unk, &mon); if(FAILED(hres)) return hres; IUnknown_Release(unk); pibc = NULL; }else { IMoniker_AddRef(mon = pimkName); } prepare_for_binding(This, mon, FALSE); call_docview_84(This->doc_obj); hres = set_moniker(This->window, mon, NULL, pibc, NULL, TRUE); IMoniker_Release(mon); if(FAILED(hres)) return hres; return start_binding(This->window->pending_window, (BSCallback*)This->window->pending_window->bscallback, pibc); }
static HRESULT IOCS_Attach( IOCS *This, HWND hWnd, IUnknown *pUnkControl ) /* subclass hWnd */ { This->hWnd = hWnd; IUnknown_QueryInterface( pUnkControl, &IID_IOleObject, (void**)&This->control ); IOleObject_SetClientSite( This->control, &This->IOleClientSite_iface ); SetWindowLongPtrW( hWnd, GWLP_USERDATA, (ULONG_PTR) This ); This->OrigWndProc = (WNDPROC)SetWindowLongPtrW( hWnd, GWLP_WNDPROC, (ULONG_PTR) AtlHost_wndproc ); return S_OK; }
void WebBrowser_OleObject_Destroy(WebBrowser *This) { if(This->client) IOleObject_SetClientSite(OLEOBJ(This), NULL); if(This->container) IOleContainer_Release(This->container); if(This->frame) IOleInPlaceFrame_Release(This->frame); if(This->uiwindow) IOleInPlaceUIWindow_Release(This->uiwindow); }
static HRESULT IOCS_Detach( IOCS *This ) /* remove subclassing */ { if ( This->hWnd ) { SetWindowLongPtrW( This->hWnd, GWLP_WNDPROC, (ULONG_PTR) This->OrigWndProc ); SetWindowLongPtrW( This->hWnd, GWLP_USERDATA, 0 ); This->hWnd = NULL; } if ( This->control ) { IOleObject *control = This->control; This->control = NULL; IOleObject_SetClientSite( control, NULL ); IOleObject_Release( control ); } return S_OK; }
HRESULT dochost_object_available(DocHost *This, IUnknown *doc) { READYSTATE ready_state; task_header_t *task; IOleObject *oleobj; HRESULT hres; IUnknown_AddRef(doc); This->document = doc; hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); if(SUCCEEDED(hres)) { CLSID clsid; hres = IOleObject_GetUserClassID(oleobj, &clsid); if(SUCCEEDED(hres)) TRACE("Got clsid %s\n", IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid)); hres = IOleObject_SetClientSite(oleobj, &This->IOleClientSite_iface); if(FAILED(hres)) FIXME("SetClientSite failed: %08x\n", hres); IOleObject_Release(oleobj); }else { FIXME("Could not get IOleObject iface: %08x\n", hres); } /* FIXME: Call SetAdvise */ task = heap_alloc(sizeof(*task)); push_dochost_task(This, task, object_available_proc, FALSE); hres = get_doc_ready_state(This, &ready_state); if(SUCCEEDED(hres)) { if(ready_state == READYSTATE_COMPLETE) push_ready_state_task(This, READYSTATE_COMPLETE); if(ready_state != READYSTATE_COMPLETE || This->doc_navigate) advise_prop_notif(This, TRUE); } return S_OK; }
static HRESULT IOCS_Detach( IOCS *This ) /* remove subclassing */ { if ( This->hWnd ) { SetWindowLongPtrW( This->hWnd, GWLP_WNDPROC, (ULONG_PTR) This->OrigWndProc ); RemovePropW( This->hWnd, wine_atl_iocsW); This->hWnd = NULL; } if ( This->control ) { IOleObject *control = This->control; This->control = NULL; IOleObject_Close( control, OLECLOSE_NOSAVE ); IOleObject_SetClientSite( control, NULL ); IOleObject_Release( control ); } return S_OK; }
/****************************************************************************** * OleCreate [OLE32.89] * */ HRESULT WINAPI OleCreate( REFCLSID rclsid, REFIID riid, DWORD renderopt, LPFORMATETC pFormatEtc, LPOLECLIENTSITE pClientSite, LPSTORAGE pStg, LPVOID* ppvObj) { HRESULT hres, hres1; IUnknown * pUnk = NULL; FIXME("\n\t%s\n\t%s stub!\n", debugstr_guid(rclsid), debugstr_guid(riid)); if (SUCCEEDED((hres = CoCreateInstance(rclsid, 0, CLSCTX_INPROC_SERVER, riid, (LPVOID*)&pUnk)))) { if (pClientSite) { IOleObject * pOE; IPersistStorage * pPS; if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IOleObject, (LPVOID*)&pOE)))) { TRACE("trying to set clientsite %p\n", pClientSite); hres1 = IOleObject_SetClientSite(pOE, pClientSite); TRACE("-- result 0x%08lx\n", hres1); IOleObject_Release(pOE); } if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IPersistStorage, (LPVOID*)&pPS)))) { TRACE("trying to set stg %p\n", pStg); hres1 = IPersistStorage_InitNew(pPS, pStg); TRACE("-- result 0x%08lx\n", hres1); IPersistStorage_Release(pPS); } } } *ppvObj = pUnk; TRACE("-- %p \n", pUnk); return hres; }
static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg, LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect) { WebBrowser *This = impl_from_IOleObject(iface); TRACE("(%p)->(%d %p %p %d %p %s)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, wine_dbgstr_rect(lprcPosRect)); /* restore closed client site if we have one */ if(!This->client && This->client_closed) { IOleClientSite *client = This->client_closed; This->client_closed = NULL; IOleObject_SetClientSite(iface, client); IOleClientSite_Release(client); } switch (iVerb) { case OLEIVERB_SHOW: TRACE("OLEIVERB_SHOW\n"); return activate_ui(This, pActiveSite); case OLEIVERB_UIACTIVATE: TRACE("OLEIVERB_UIACTIVATE\n"); return activate_ui(This, pActiveSite); case OLEIVERB_INPLACEACTIVATE: TRACE("OLEIVERB_INPLACEACTIVATE\n"); return activate_inplace(This, pActiveSite); case OLEIVERB_HIDE: TRACE("OLEIVERB_HIDE\n"); if(This->inplace) IOleInPlaceSiteEx_OnInPlaceDeactivate(This->inplace); if(This->shell_embedding_hwnd) ShowWindow(This->shell_embedding_hwnd, SW_HIDE); return S_OK; default: FIXME("stub for %d\n", iVerb); break; } return E_NOTIMPL; }
HRESULT CIETabProcControl::SetClientSite(IOleClientSite* pClientSite) { if (pClientSite) { CComPtr<IServiceProvider> spIsp, spIsp2; pClientSite->QueryInterface(IID_IServiceProvider, (void **)&spIsp); if (spIsp) { spIsp->QueryService(SID_STopLevelBrowser, IID_IServiceProvider, (void **)&spIsp2); if (spIsp2) { spIsp2->QueryService(SID_SWebBrowserApp, IID_IWebBrowser2, (void **)&m_spWebBrowser); } } } return IOleObject_SetClientSite(pClientSite); }
static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk) { BindStatusCallback *This = BINDSC_THIS(iface); task_header_t *task; IOleObject *oleobj; HRESULT hres; TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk); IUnknown_AddRef(punk); This->doc_host->document = punk; hres = IUnknown_QueryInterface(punk, &IID_IOleObject, (void**)&oleobj); if(SUCCEEDED(hres)) { CLSID clsid; hres = IOleObject_GetUserClassID(oleobj, &clsid); if(SUCCEEDED(hres)) TRACE("Got clsid %s\n", IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid)); hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(This->doc_host)); if(FAILED(hres)) FIXME("SetClientSite failed: %08x\n", hres); IOleObject_Release(oleobj); }else { FIXME("Could not get IOleObject iface: %08x\n", hres); } /* FIXME: Call SetAdvise */ /* FIXME: Call Invoke(DISPID_READYSTATE) */ task = heap_alloc(sizeof(*task)); push_dochost_task(This->doc_host, task, object_available_proc, FALSE); return S_OK; }
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_Close(IOleObject *iface, DWORD dwSaveOption) { WebBrowser *This = impl_from_IOleObject(iface); TRACE("(%p)->(%d)\n", This, dwSaveOption); if(dwSaveOption != OLECLOSE_NOSAVE) { FIXME("unimplemented flag: %x\n", dwSaveOption); return E_NOTIMPL; } if(This->doc_host.frame) IOleInPlaceFrame_SetActiveObject(This->doc_host.frame, NULL, NULL); if(This->uiwindow) IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, NULL, NULL); if(This->inplace) { IOleInPlaceSiteEx_OnUIDeactivate(This->inplace, FALSE); IOleInPlaceSiteEx_OnInPlaceDeactivate(This->inplace); } return IOleObject_SetClientSite(iface, NULL); }
void detach_plugin_host(PluginHost *host) { HRESULT hres; TRACE("%p\n", host); if(!host->doc) return; if(host->ip_object) { if(host->ui_active) IOleInPlaceObject_UIDeactivate(host->ip_object); IOleInPlaceObject_InPlaceDeactivate(host->ip_object); } if(host->plugin_unk) { IOleObject *ole_obj; hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IOleObject, (void**)&ole_obj); if(SUCCEEDED(hres)) { if(!host->ip_object) IOleObject_Close(ole_obj, OLECLOSE_NOSAVE); IOleObject_SetClientSite(ole_obj, NULL); IOleObject_Release(ole_obj); } } if(host->element) { host->element->plugin_host = NULL; host->element = NULL; } list_remove(&host->entry); list_init(&host->entry); host->doc = NULL; }
static void activate_plugin(PluginHost *host) { IClientSecurity *client_security; IQuickActivate *quick_activate; IOleObject *ole_obj = NULL; IOleCommandTarget *cmdtrg; IViewObjectEx *view_obj; IDispatchEx *dispex; IDispatch *disp; RECT rect; HRESULT hres; if(!host->plugin_unk) return; /* Note native calls QI on plugin for an undocumented IID and CLSID_HTMLDocument */ /* FIXME: call FreezeEvents(TRUE) */ hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IClientSecurity, (void**)&client_security); if(SUCCEEDED(hres)) { FIXME("Handle IClientSecurity\n"); IClientSecurity_Release(client_security); return; } hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IQuickActivate, (void**)&quick_activate); if(SUCCEEDED(hres)) { QACONTAINER container = {sizeof(container)}; QACONTROL control = {sizeof(control)}; TRACE("Using IQuickActivate\n"); container.pClientSite = &host->IOleClientSite_iface; container.dwAmbientFlags = QACONTAINER_SUPPORTSMNEMONICS|QACONTAINER_MESSAGEREFLECT|QACONTAINER_USERMODE; container.pAdviseSink = &host->IAdviseSinkEx_iface; container.pPropertyNotifySink = &host->IPropertyNotifySink_iface; hres = IQuickActivate_QuickActivate(quick_activate, &container, &control); IQuickActivate_Release(quick_activate); if(FAILED(hres)) FIXME("QuickActivate failed: %08x\n", hres); }else { DWORD status = 0; hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IOleObject, (void**)&ole_obj); if(SUCCEEDED(hres)) { hres = IOleObject_GetMiscStatus(ole_obj, DVASPECT_CONTENT, &status); TRACE("GetMiscStatus returned %08x %x\n", hres, status); hres = IOleObject_SetClientSite(ole_obj, &host->IOleClientSite_iface); IOleObject_Release(ole_obj); if(FAILED(hres)) { FIXME("SetClientSite failed: %08x\n", hres); return; } }else { TRACE("Plugin does not support IOleObject\n"); } } load_plugin(host); if(ole_obj) { hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IViewObjectEx, (void**)&view_obj); if(SUCCEEDED(hres)) { DWORD view_status = 0; hres = IViewObjectEx_SetAdvise(view_obj, DVASPECT_CONTENT, 0, (IAdviseSink*)&host->IAdviseSinkEx_iface); if(FAILED(hres)) WARN("SetAdvise failed: %08x\n", hres); hres = IViewObjectEx_GetViewStatus(view_obj, &view_status); IViewObjectEx_Release(view_obj); TRACE("GetViewStatus returned %08x %x\n", hres, view_status); } } update_readystate(host); /* NOTE: Native QIs for IActiveScript, an undocumented IID, IOleControl and IRunnableObject */ hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IDispatchEx, (void**)&dispex); if(SUCCEEDED(hres)) { FIXME("Use IDispatchEx\n"); host->disp = (IDispatch*)dispex; }else { hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IDispatch, (void**)&disp); if(SUCCEEDED(hres)) host->disp = disp; else TRACE("no IDispatch iface\n"); } hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IOleCommandTarget, (void**)&cmdtrg); if(SUCCEEDED(hres)) { FIXME("Use IOleCommandTarget\n"); IOleCommandTarget_Release(cmdtrg); } hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IOleObject, (void**)&ole_obj); if(FAILED(hres)) { FIXME("Plugin does not support IOleObject\n"); return; } if(ole_obj) { get_pos_rect(host, &rect); hres = IOleObject_DoVerb(ole_obj, OLEIVERB_INPLACEACTIVATE, NULL, &host->IOleClientSite_iface, 0, host->hwnd, &rect); IOleObject_Release(ole_obj); if(FAILED(hres)) WARN("DoVerb failed: %08x\n", hres); } if(host->ip_object) { HWND hwnd; hres = IOleInPlaceObject_GetWindow(host->ip_object, &hwnd); if(SUCCEEDED(hres)) TRACE("hwnd %p\n", hwnd); } }
static void test_oleobject(void) { DWORD status, dpi_x, dpi_y; IOleClientSite *site; IOleObject *obj; SIZEL extent; HRESULT hr; HDC hdc; hr = CoCreateInstance(&CLSID_ScriptControl, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IOleObject, (void**)&obj); ok(hr == S_OK, "got 0x%08x\n", hr); if (0) /* crashes on w2k3 */ hr = IOleObject_GetMiscStatus(obj, DVASPECT_CONTENT, NULL); status = 0; hr = IOleObject_GetMiscStatus(obj, DVASPECT_CONTENT, &status); ok(hr == S_OK, "got 0x%08x\n", hr); ok(status != 0, "got 0x%08x\n", status); hr = IOleObject_SetClientSite(obj, &testclientsite); ok(hr == S_OK, "got 0x%08x\n", hr); if (0) /* crashes on w2k3 */ hr = IOleObject_GetClientSite(obj, NULL); hr = IOleObject_GetClientSite(obj, &site); ok(hr == S_OK, "got 0x%08x\n", hr); ok(site == &testclientsite, "got %p, %p\n", site, &testclientsite); IOleClientSite_Release(site); hr = IOleObject_SetClientSite(obj, NULL); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IOleObject_GetClientSite(obj, &site); ok(hr == S_OK, "got 0x%08x\n", hr); ok(site == NULL, "got %p\n", site); /* extents */ hdc = GetDC(0); dpi_x = GetDeviceCaps(hdc, LOGPIXELSX); dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); ReleaseDC(0, hdc); memset(&extent, 0, sizeof(extent)); hr = IOleObject_GetExtent(obj, DVASPECT_CONTENT, &extent); ok(hr == S_OK, "got 0x%08x\n", hr); ok(extent.cx == MulDiv(38, 2540, dpi_x), "got %d\n", extent.cx); ok(extent.cy == MulDiv(38, 2540, dpi_y), "got %d\n", extent.cy); extent.cx = extent.cy = 0xdeadbeef; hr = IOleObject_GetExtent(obj, DVASPECT_THUMBNAIL, &extent); ok(hr == DV_E_DVASPECT, "got 0x%08x\n", hr); ok(extent.cx == 0xdeadbeef, "got %d\n", extent.cx); ok(extent.cy == 0xdeadbeef, "got %d\n", extent.cy); extent.cx = extent.cy = 0xdeadbeef; hr = IOleObject_GetExtent(obj, DVASPECT_ICON, &extent); ok(hr == DV_E_DVASPECT, "got 0x%08x\n", hr); ok(extent.cx == 0xdeadbeef, "got %d\n", extent.cx); ok(extent.cy == 0xdeadbeef, "got %d\n", extent.cy); extent.cx = extent.cy = 0xdeadbeef; hr = IOleObject_GetExtent(obj, DVASPECT_DOCPRINT, &extent); ok(hr == DV_E_DVASPECT, "got 0x%08x\n", hr); ok(extent.cx == 0xdeadbeef, "got %d\n", extent.cx); ok(extent.cy == 0xdeadbeef, "got %d\n", extent.cy); IOleObject_Release(obj); }
static void test_packager(void) { IOleObject *oleobj; IPersistStorage *persist; DWORD len, bytes_read, status; HRESULT hr; HANDLE file; WCHAR filename[MAX_PATH]; char contents[11]; BOOL br, extended = FALSE; static const WCHAR filename3W[] = {'f','i','l','e','n','a','m','e','3','.','t','x','t',0}; hr = CoCreateInstance(&CLSID_Package, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, &IID_IOleObject, (void**)&oleobj); ok(hr == S_OK || hr == REGDB_E_CLASSNOTREG, "CoCreateInstance(CLSID_Package) failed: %08x\n", hr); if(hr == S_OK){ IOleObject_Release(oleobj); /* older OSes store temporary files in obscure locations, so don't run * the full tests on them */ extended = TRUE; }else win_skip("Older OS doesn't support modern packager\n"); hr = CoCreateInstance(&CLSID_Package_Alt, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, &IID_IOleObject, (void**)&oleobj); ok(hr == S_OK, "CoCreateInstance(CLSID_Package_Alt) failed: %08x\n", hr); hr = IOleObject_SetClientSite(oleobj, NULL); ok(hr == S_OK, "SetClientSite failed: %08x\n", hr); hr = IOleObject_SetClientSite(oleobj, &clientsite); ok(hr == S_OK, "SetClientSite failed: %08x\n", hr); hr = IOleObject_GetMiscStatus(oleobj, DVASPECT_CONTENT, NULL); ok(hr == E_INVALIDARG, "GetMiscStatus failed: %08x\n", hr); hr = IOleObject_GetMiscStatus(oleobj, DVASPECT_CONTENT, &status); ok(hr == S_OK, "GetMiscStatus failed: %08x\n", hr); ok(status == OLEMISC_ONLYICONIC || status == OLEMISC_CANTLINKINSIDE /* winxp */, "Got wrong DVASPECT_CONTENT status: 0x%x\n", status); hr = IOleObject_QueryInterface(oleobj, &IID_IPersistStorage, (void**)&persist); ok(hr == S_OK, "QueryInterface(IPersistStorage) failed: %08x\n", hr); hr = IPersistStorage_Load(persist, &stg); ok(hr == S_OK, "Load failed: %08x\n", hr); if(extended){ len = GetTempPathW(sizeof(filename) / sizeof(*filename), filename); lstrcpyW(filename + len, filename3W); file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); ok(file != INVALID_HANDLE_VALUE, "Couldn't find temporary file %s: %u\n", wine_dbgstr_w(filename), GetLastError()); br = ReadFile(file, contents, sizeof(contents), &bytes_read, NULL); ok(br == TRUE, "ReadFile failed\n"); ok(bytes_read == 10, "Got wrong file size: %u\n", bytes_read); ok(!memcmp(contents, "some text\n", 10), "Got wrong file contents\n"); CloseHandle(file); } hr = IOleObject_Close(oleobj, OLECLOSE_NOSAVE); ok(hr == S_OK, "Close failed: %08x\n", hr); if(extended){ file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); ok(file != INVALID_HANDLE_VALUE, "Temporary file shouldn't be deleted\n"); CloseHandle(file); } IPersistStorage_Release(persist); IOleObject_Release(oleobj); if(extended){ file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); ok(file == INVALID_HANDLE_VALUE, "Temporary file should be deleted\n"); } }
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); }