A little hint:
  IWebBrowser2::GetDocument or CHtmlView::GetHtmlDocument

解决方案 »

  1.   

    我也有同样的问题。
    得到的Document是类,其结构不知道。
      

  2.   

    www.codeguru.com的IE Programming版有实现view source的源程序,略加修改可适用于你的想法。
    我感到奇怪,为什么大家都不去codeguru?多好的站点
      

  3.   

    用wininet类,得到httpfile后,read到本地就行了
      

  4.   

    //USE MSHTML
    void CMyHtmlView::OnSource() 
    {
             IHTMLDocument2 doc;
             HGLOBAL hMem = NULL;
    LPSTREAM pStream = NULL;
    IPersistStreamInit *pPersistStream = NULL;
    ULARGE_INTEGER uli;
    HRESULT hr;
             doc=GetHtmlDocument();
    hr = ptrDoc.QueryInterface(IID_IPersistStreamInit, &pPersistStream);
    if(pPersistStream == NULL)
    return;
    if(FAILED(pPersistStream->GetSizeMax(&uli)))
    {
    pPersistStream->Release();
    return;
    }
    uli.LowPart = 65536;
    hMem = ::GlobalAlloc(GPTR, uli.LowPart);
    if(hMem == NULL)
    {
    pPersistStream->Release();
    return;
    } hr = ::CreateStreamOnHGlobal(hMem, TRUE, &pStream);
    if(FAILED(hr))
    {
    pPersistStream->Release();
    ::GlobalFree(hMem);
    return;
    }
    hr = pPersistStream->Save(pStream, TRUE);

    AfxMessageBox((LPCTSTR)hMem);
    ::GlobalUnlock(hMem);
    ::GlobalFree(hMem);
    hr = pPersistStream->Release();
    pStream->Release();
    }
      

  5.   

    This is the code for implementing the "View Source" option in Internet Explorer 
    void CMyBrowser::OnViewSource() 
    {
    CWnd* pWnd = NULL;  CWnd* pwndShell = m_WebBrowser2.GetWindow(GW_CHILD); // get the webbrowser window pointer if (pwndShell) 

    pWnd = pwndShell->GetWindow(GW_CHILD);  //get the child window pointer


    if(pWnd != NULL) 

    WPARAM wParam = MAKELONG(IDM_VIEWSOURCE, 1);  //convert to unsigned 32 bit value and pass it to WPARAM
    pWnd->SendMessage(WM_COMMAND, wParam, (LPARAM)pWndHTML->m_hWnd); //cool send a message to retreive the source.

    }
    是http://www.vckbase.com/document/上面的一篇文章啊