下面使用DELPHI获得webbrowers 的滚动条位置的代码:
Delphi(Pascal) codevar
  vElement: IHTMLElement2;
begin
  if not Assigned(WebBrowser1.Document) then Exit;
  vElement :=
    (WebBrowser1.Document as IHTMLDocument3).documentElement as IHTMLElement2;
  if not Assigned(vElement) then
    vElement := (WebBrowser1.Document as IHTMLDocument2).Body as IHTMLElement2;
  Edit2.Text := IntToStr(vElement.scrollTop);
end;那位朋友帮忙翻译成VC++的代码?

解决方案 »

  1.   

    IDispatch* disp = NULL;
    if (m_pWebBrowser2)
      m_pWebBrowser2->get_Document((IDispatch **)&disp);
    if(disp)
      disp->QueryInterface(IID_IHTMLDocument3, (void**)&m_doc);
    if (m_doc)
      m_doc->documentElement(&pElement);    
    if(!pElement)
    {
        disp->QueryInterface(IID_IHTMLDocument2, (void**)&m_doc);
        m_doc->get_body(&pElement); 
    }
    int int_temp = pElement->scrollTop(); 问题是 IID_IHTMLDocument3包含在哪个头文件中
      

  2.   

    1、升级你的SDK
    2、用VC7/VC8
      

  3.   

    安装了vs6sp6 还是没有IHTMLDOcument3,升级包安装在别的目录下如何使用呢?