我用WebBrower控件,用IPersistStreamInit结构获取了当前网页的源文件,但是如果该网页是框架结构,就拿不到正确的源文件了,还有表单之类的,请教有什么解决方法吗??另一个就是如何将页面上的文字信息全部得到,比如CTRA+A复制下来粘贴到记事本里的。
等..............................待

解决方案 »

  1.   

    http://support.microsoft.com/support/kb/articles/Q271/8/68.ASP
    http://weborama.blogspot.com/2004/09/mshtml-hosting-odds-ends.html
      

  2.   

    Retrieving the HTML of the current selection 
    If you want to limit the HTML to just what a user has selected, instead of the entire document, we can use the IHTMLXxx COM interfaces. The first thing you need to do is get access to the IHTMLDocument interface for the current document. IWebBrowser2 gives you access using it's Document property. The Document property returns an IDispatch interface, so we need to QueryInterface the IDispatch interface for an IHTMLDocument interface, like so (raw C++): 
    IDispatch* pDocDisp = 0;
    HRESULT hr = pWebBrowser->get_Document(&pDocDisp);IHTMLDocument2* pDoc = 0;
    hr = pDocDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pDoc);
    if (SUCCEEDED(hr)) {    //...    pDoc->Release();
    }pDocDisp->Release();The IHTMLXxx interfaces follow the W3C DOM specification used for JavaScript very closely. If your familiar with those objects, the IHTMLXxx interface will be easy to grasp. In fact, if you know how to do something using JavaScript, you can duplicate it your compiled code using the IHTMLXxx interfaces. That said, you can get the current selection as a IHTMLTxtRange from the document element. Once you have a text range, you can retrieve the plain text or HTML text as shown below: 
    IHTMLDocument2* pDoc = ...;IHTMLSelectionObject* pSelection = 0;
    HRESULT hr = pDoc->get_selection(&pSelection);
    if (SUCCEEDED(hr)) {
       IDispatch* pDispRange = 0;
       hr = pSelection->createRange(&pDispRange);
       if (SUCCEEDED(hr)) {
          IHTMLTxtRange* pTextRange = 0;
          hr = pDispRange->QueryInterface(IID_IHTMLTxtRange, (void**)&pTextRange);
          if (SUCCEEDED(hr)) {
             CComBSTR sText;
             pTextRange->get_text(&sText);
             // or
             pTextRange->get_htmlText(&sText);
             //...
             pTextRange->Release();
          }
          pDispRange->Release();
       }
       pSelection->Release();
    }pDoc->Release();