HRESULT hr = S_OK;
LPDISPATCH pDispatch = m_wndBrowser.get_Document();
if( pDispatch != NULL )
{
IHTMLDocument2* pHtmlDoc=NULL;
hr = pDispatch->QueryInterface( __uuidof( IHTMLDocument2 ),(void**)&pHtmlDoc );
IHTMLWindow2* pWindow;
if(pHtmlDoc!=NULL)
{
hr = pHtmlDoc->get_parentWindow(&pWindow);
pHtmlDoc->Release();
}
ASSERT( SUCCEEDED( hr ) );
long docheight=0;
IHTMLElement* pe=NULL;
pHtmlDoc->get_body(&pe);
IHTMLTextContainer* pe2=NULL;
if(pe!=NULL)
{
pe->QueryInterface(&pe2);
pe->Release();
}
if(pe2!=NULL)
{
pe2->get_scrollHeight(&docheight);
pe2->Release();
}
if(pWindow!=NULL&&docheight>0)
{
pWindow->scrollTo(0,docheight);
pWindow->Release();
}
pDispatch->Release();
}
|