我在CHtmlView中怎么得到网页中的控件(如输入框)?
有人告诉我用IHTMLDocument2接口,可是怎么得到呢?难道能对CHtmlView用QueryInterface????

解决方案 »

  1.   

    IUnknonw* punk=m_wndBrowser.GetControlUnknown();
    punk->QueryInterface(IID_IWebBrowser2, (void**)pwb);
    pwb->get_Document(&pdisp);
    pdisp->QueryInterface(IID_IHTMLDocument2, (void**)pdoc);
    次序是这样,加上判断。
      

  2.   

    这样是不是也可以?HRESULT CHtmlCtrl::GetDHtmlDocument(IHTMLDocument2** ppHtmlDocument2)
    {

    LPDISPATCH pDoc=GetDocument();
    if(pDoc){
    HRESULT hr=pDoc->QueryInterface(IID_IHTMLDocument2,
    reinterpret_cast<void**> (ppHtmlDocument2));
    pDoc->Release();
    return hr;
    }
    else{
    return OLE_E_BLANK;
    }
    }
      

  3.   

    http://expert.csdn.net/Expert/topic/934/934618.xml
    http://expert.csdn.net/Expert/topic/1690/1690557.xml