Re: put_scrollTop only work once!



Sorry about this, but I´ve been changing this code all day trying to
make it work, well I've made the changes, but I had no clue how using
SysAllocString, so i just passed am CComBSTR instead, here is how it
is;

CComPtr<IHTMLElementCollection> pHtmlEleCol;

m_pHtmlDocument2->get_all(&pHtmlEleCol);

if(!pHtmlEleCol)
{
return;
}

long uTotal = 0;
pHtmlEleCol->get_length(&uTotal);

CComPtr <IDispatch> pDisCol;

CComVariant var, varEmpty;

var.vt = VT_BSTR;
var.bstrVal = CComBSTR("SPAN");

pHtmlEleCol->tags(var,&pDisCol);

SysFreeString(var.bstrVal);

if(pDisCol)
{
CComPtr<IHTMLElementCollection> pSpanCol;
pDisCol.QueryInterface(&pSpanCol);

if(pSpanCol)
{
long uLen = 0;
pSpanCol->get_length(&uLen);

if(uLen > 0)
{
memset(&var,0,sizeof(VARIANT));
memset(&varEmpty,0,sizeof(VARIANT));
varEmpty.vt = VT_EMPTY;
var.vt = VT_I4;
var.iVal = uLen-1;

CComPtr <IDispatch> pDisEle;

pSpanCol->item(var,varEmpty,&pDisEle);

if(pDisEle)
{
CComPtr <IHTMLElement> pEle;

pDisEle.QueryInterface(&pEle);

if(pEle)
{
CComVariant vScroll;
vScroll.vt = VT_BOOL;
vScroll.boolVal = TRUE;

CComBSTR bstr;
pEle->get_innerText(&bstr);

hr = pEle->scrollIntoView(vScroll);

}
}
}
}
}

.



Relevant Pages