IHTMLElement2 接口的getBoundingClientRect函数,我是在线程中调用的,用了webbrower控件,在IE6下都使用正常
可到了IE8下就报内存错误,有高手解决下没。IE8下只要是线程中调用getBoundingClientRect都会报错,不在线程中调用就正常。搞不懂啊,那位高手帮忙解决下啊。CComQIPtr<IHTMLElement2> pElement2(pElement);
CComPtr<IHTMLRect> BoundingRect;
if (pElement2)
{

if (SUCCEEDED(pElement2->getBoundingClientRect(&BoundingRect)) && BoundingRect)
{
BoundingRect->get_top(&Top);
BoundingRect->get_left(&Left); 
}
else
{
Top = 0; Left = 0;
}
}

解决方案 »

  1.   

    mshtml的接口本来就应该在UI线程中调用。在后台线程中需要Marshal/UnMarshal, 效率还不如在UI线程中做
      

  2.   

     HRESULT hr=  pElement2->getBoundingClientRect(&BoundingRect)) 
    这个hr的值具体是多少?
    还有,如楼上所说,如果你自己创建了一个线程的话,传递接口需要Marshal。
    同时你再测一下,如果不是调用这个方法,而是调用接口的其他方法,会出错么