HRESULT res22 = spHTML2_2->get_body(&spHTML_E2); //获取到elmet
res = spHTML2_2->QueryInterface(IID_IHTMLElement2, (LPVOID *)&spHTML_Element); 获取elememnt2res = spHTML_Element->get_scrollLeft(&c); 
res = spHTML_Element->get_scrollTop(&d);然后获取带left和top一直是0 我被搞惆怅了,,亲们是否有解决方案或者有遇到过的 愁死我了

解决方案 »

  1.   

    中间缺少了判断,你自己添加一下
    LPDISPATCH lpDisp = GetHtmlDocument( );
    IHTMLDocument2 *pDoc2 = NULL;
    lpDisp->QueryInterface(IID_IHTMLDocument2,(void **)&pDoc2);
    lpDisp->Release(); IHTMLDocument3 *pDoc3 = NULL;
    pDoc2->QueryInterface(IID_IHTMLDocument3,(void **)&pDoc3);
    pDoc2->Release(); IHTMLElement *pElem = NULL;
    pDoc3->get_documentElement(&pElem);
    pDoc3->Release(); IHTMLElement2 *pElem2 = NULL;
    pElem->QueryInterface(IID_IHTMLElement2,(void **)&pElem2);
    pElem->Release(); long c,d;
    HRESULT res = pElem2->get_scrollLeft(&c); 
    res = pElem2->get_scrollTop(&d);
    pElem2->Release();