<html>
<head>
</head>
<body>
<iframe id='fram1' src='about:blank1' ></iframe>
</body>
</html>已经有了IFRAME fram1的IWebBrowser2指针 pChild;
如何获取其父页面的IWebBrowser2 pParrent?

解决方案 »

  1.   

    ,,,从你的xml文件中什么东西都看不出来。
      

  2.   

    CComQIPtr< IDispatch >pDis;
    pBroser->get_Parent(&pDis);
    CComQIPtr<IHTMLDocument2> p(pDis);
    if(p)
    {}
      

  3.   

    你的代码执行环境是什么?
    如果是BHO,SetSite被调用时能捕获到根IWebBrowser2;
    如果是自制浏览器,直接就能得到根IWebBrowser2。
    如果仅仅通过DOM来获得,按照下面的步骤:
    pChild->get_document
    IHTMLDocument2->QueryInterface
    IHTMLDocument3->get_parentDocument
    IHTMLDocument3->QueryInterface
    IOleObject->GetClientSite
    IOleClientSite->GetContainer
    IOleContainer->QueryInterface(IID_IWebBrowser2,...)
      

  4.   

    晕,楼主到底想得到IHTMLDocument2还是IWebBrowser2?
      

  5.   

    直接get_Parent
    不过奇怪的是
    CComQIPtr< IDispatch >pDis;
     pBroser->get_Parent(&pDis);//return S_OK;
    IDispatch* pDis;
    pBroser->get_Parent(&pDis);却失败了
      

  6.   

    IHTMLDocument2 queryinterface不能得到IWebBrowser2?
      

  7.   

    麻烦胡兄给指点下http://topic.csdn.net/u/20080130/09/e4eb5c33-056f-4ca0-be69-962cf2b229fe.html
      

  8.   

    每个WebBrowser是一个ActiveDocument容器,IHTMLDocument2只是一个ActiveDocument,容器中的对象不能直接查询到容器的接口,因为对象能放到任何容器中,不一定是WebBrowser
      

  9.   


    CComQIPtr< IDispatch >pDis;
    pBroser->get_Parent(&pDis);
    CComQIPtr<IHTMLDocument2> p(pDis);                                 
    IHTMLDocument2-> QueryInterface 
    IHTMLDocument3-> QueryInterface 
    IOleObject-> GetClientSite 
    IOleClientSite-> GetContainer 
    IOleContainer-> QueryInterface(IID_IWebBrowser2,...)
      

  10.   

    WebBrowser有几个属性 get_parent/get_Application,MSDN上没有详细解释,我也不清楚这几个属性获得的到底是什么,可能是WebBrowser,也可能是IHTMLDocument,也可能取到NULL值,需要试验才能知道
      

  11.   

    胡柏华兄,帮我看看
    http://topic.csdn.net/u/20080130/09/e4eb5c33-056f-4ca0-be69-962cf2b229fe.html我那刷新还没搞定呀!~
    我发这个贴是为了解决刷新:
     刷新一个页面,则该页面中的iframe都会收到documentcomplete事件,那么对每个页面都插入一个iframe,documentcomplete的时候判断是不是插入的iframe如果是的话,则认为iframe的上一级页面是所要获取的,结果失败了