我用IE打开一个页面,页面包含Frame,我想连同Frame里边的内容一并保存,请问该如何编程达到此目的,谢谢!

解决方案 »

  1.   

    把内容都取进文档里,在serailize
      

  2.   

    可以试试分次保存:
    首先框架主页xxx.htm,得ihtmldocument2
    从ihtmldocument2->get_frames->item->得到frame的ihtmldocuemnt2,然后再保存,以此类推。但可能不是最好的办法.
      

  3.   

    本人刚刚接触IE编程,
    能否给点示例代码?
    比如如何得到ihtmldocument2对象?谢谢!
      

  4.   

    我的代码(在CHtmlView中):
    LPDISPATCH lpDispatch = NULL;
    IPersistFile *lpPersistFile = NULL; // m_ctrl is an instance of the Web Browser control
    lpDispatch = GetHtmlDocument();
    lpDispatch->QueryInterface(IID_IPersistFile, (void**)&lpPersistFile);
    IHTMLDocument2 * lpDoc = NULL;
    if(lpDispatch->QueryInterface(IID_IHTMLDocument2, (void ** )&lpDoc)==S_OK)
    {
    IHTMLFramesCollection2 * iframes = NULL;
    lpDoc->get_frames(&iframes);
                      //现在我已经得到了frame的Collection了,请问如何得到frame的document,谢谢!
    } lpPersistFile->Save(L"c:\\htmlpage.html",0);
    lpPersistFile->Release();
    lpDispatch->Release();