一般得到的都是主框架页面的IHTMLDocument接口。
如何通过这个接口来获得其子Frame页面的IDispatch(IHTMLDocument)接口?

解决方案 »

  1.   

    Knowledge Base  
    PSS ID Number: 196340
    HOWTO: Get the WebBrowser Object Model of an HTML Frame
    // Get the IDispatch of the document
    LPDISPATCH lpDisp = NULL;
    lpDisp = m_webBrowser.GetDocument();if (lpDisp)
    {
       IOleContainer* pContainer;   // Get the container
       HRESULT hr = lpDisp->QueryInterface(IID_IOleContainer,
                                           (void**)&pContainer);
       lpDisp->Release();   if (FAILED(hr))
          return hr;   IEnumUnknown* pEnumerator;   // Get an enumerator for the frames
       hr = pContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator);
       pContainer->Release();   if (FAILED(hr))
          return hr;   IUnknown* pUnk;
       ULONG uFetched;   // Enumerate and refresh all the frames
       for (UINT i = 0; S_OK == pEnumerator->Next(1, &pUnk, &uFetched); i++)
       {
          // QI for IWebBrowser here to see if we have an embedded browser
          IWebBrowser2* pBrowser;      hr = pUnk->QueryInterface(IID_IWebBrowser2, (void**)&pBrowser);
          pUnk->Release();      if (SUCCEEDED(hr))
          {
             // Refresh the frame
             pBrowser->Refresh();
             pBrowser->Release();
          }
       }   pEnumerator->Release();
    }
    注意跨跨框架访问需要考虑安全性设置。
      

  2.   

    谢谢蒋老大。
    有没有可能通过IHTMLFramesCollection2接口来获得Frame的IDispatch接口?蒋老大;
    还请帮忙看看
    http://expert.csdn.net/Expert/topic/1901/1901473.xml?temp=.93771
    我自己回了3次后就不能再回了。