Exemplo n.º 1
0
Arquivo: atl_ax.c Projeto: devyn/wine
static HRESULT IOCS_Init( IOCS *This )
{
    RECT rect;
    static const WCHAR AXWIN[] = {'A','X','W','I','N',0};

    IOleObject_SetHostNames( This->control, AXWIN, AXWIN );

    GetClientRect( This->hWnd, &rect );
    IOCS_OnSize( This, &rect );
    IOleObject_DoVerb( This->control, OLEIVERB_INPLACEACTIVATE, NULL, THIS2IOLECLIENTSITE( This ), 0, This->hWnd, &rect );

    return S_OK;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
static HRESULT WINAPI HlinkTarget_Navigate(IHlinkTarget *iface, DWORD grfHLNF, LPCWSTR pwzJumpLocation)
{
    HTMLDocument *This = impl_from_IHlinkTarget(iface);

    TRACE("(%p)->(%08x %s)\n", This, grfHLNF, debugstr_w(pwzJumpLocation));

    if(grfHLNF)
        FIXME("Unsupported grfHLNF=%08x\n", grfHLNF);
    if(pwzJumpLocation)
        FIXME("JumpLocation not supported\n");

    if(!This->doc_obj->client)
        return navigate_new_window(This->window, This->window->uri, NULL, NULL, NULL);

    return IOleObject_DoVerb(&This->IOleObject_iface, OLEIVERB_SHOW, NULL, NULL, -1, NULL, NULL);
}
Exemplo n.º 4
0
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);
    }
}
Exemplo n.º 5
0
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);
}