参数x,如果是负数就向左滚,正数向右滚;
参数y,负数向上滚,正数向下滚。
void CMainWnd::ScrollBy(IWebBrowser2 *Browser2,long x,long y)
{
HRESULT hr;
IDispatch *pDisp = NULL;
//网上查到很多例子这样用,但msdn上面说此函数只返回状态的,更新了?
//IHTMLDocument2 *pDocument = (IHTMLDocument2*)Browser2->get_Document(&pDisp);
hr = Browser2->get_Document(&pDisp);
if(hr != S_OK)
{
return;
}
IHTMLDocument2 *pDocument;
hr = pDisp->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pDocument);
if(FAILED(hr))
{
return;
}
IHTMLWindow2 *pWindow;
hr = pDocument->get_parentWindow (&pWindow);
if(hr != S_OK)
{
return;
}
pWindow->scrollBy (x,y);
}
控制页面滚动,感觉挺麻烦的,如果您有更好的方法请指教