IHTMLElement* spChildrenElement;
for(it_HtmlElem=eleVector.begin();it_HtmlElem!=eleVector.end();++it_HtmlElem)
{
for(int i=0;i<length;i++,varName=varIndex=i)//将子节点放入vector中
{
spHTMLElementCollection->item(varName,varIndex,&spDisp);
spDisp->QueryInterface(&spChildrenElement);
eleVector.push_back(spChildrenElement);
}
spChildrenElement->Release();
spChildrenElement=*it_HtmlElem;
if(spChildrenElement)//非空节点才进行处理
{
//以下为节点坐标
long offsetHeight=-1;
long offsetLeft=-1;
//long offsetParent=-1;
long offsetWidth=-1;
long offsetTop=-1;
spChildrenElement->get_offsetLeft(&offsetLeft); //此处报错
spChildrenElement->get_offsetHeight(&offsetHeight);
spChildrenElement->get_offsetWidth(&offsetWidth);
spChildrenElement->get_offsetTop(&offsetTop);
........一下省略
}
}调试模式下执行到???的地方的时候,就跳出一个对话框,说unhandled exception,Access Violation.
我怀疑是不是我从vector中取元素的时候出错了,但是没有想出为什么,请大家帮忙.
for(it_HtmlElem=eleVector.begin();it_HtmlElem!=eleVector.end();++it_HtmlElem)
{
for(int i=0;i<length;i++,varName=varIndex=i)//将子节点放入vector中
{
spHTMLElementCollection->item(varName,varIndex,&spDisp);
spDisp->QueryInterface(&spChildrenElement);
eleVector.push_back(spChildrenElement);
}
spChildrenElement->Release();
spChildrenElement=*it_HtmlElem;
if(spChildrenElement)//非空节点才进行处理
{
//以下为节点坐标
long offsetHeight=-1;
long offsetLeft=-1;
//long offsetParent=-1;
long offsetWidth=-1;
long offsetTop=-1;
spChildrenElement->get_offsetLeft(&offsetLeft); //此处报错
spChildrenElement->get_offsetHeight(&offsetHeight);
spChildrenElement->get_offsetWidth(&offsetWidth);
spChildrenElement->get_offsetTop(&offsetTop);
........一下省略
}
}调试模式下执行到???的地方的时候,就跳出一个对话框,说unhandled exception,Access Violation.
我怀疑是不是我从vector中取元素的时候出错了,但是没有想出为什么,请大家帮忙.
我怀疑是不是我从vector中取元素的时候出错了,但是没有想出为什么,请大家帮忙.
{
for(int i=0;i<length;i++,varName=varIndex=i)//将子节点放入vector中
{
spHTMLElementCollection->item(varName,varIndex,&spDisp);
spDisp->QueryInterface(&spChildrenElement);
eleVector.push_back(spChildrenElement);
}
spChildrenElement->Release();就可以执行下面的了。但是这几行为什么会影响原来的运行呢,不知道为什么
下面
spChildrenElement->get_offsetLeft(&offsetLeft);//此处报错
还要用到
不用的时候在Rlease