AI摘要
本文介绍了在Delphi中使用webBrowser控件实现自动滚动条滚动的方法。通过引入mshtml单元,获取IHTMLDocument2接口,计算滚动条的最大高度和宽度,最后使用ScrollBy方法实现滚动到最右最下。
uses mshtml;
var htmldoc: IHTMLDocument2;
MaxScrollWidth, MaxScrollHeight: Integer;
htmldoc := web.Document as IHTMLDocument2;
MaxScrollHeight := htmldoc.body.getAttribute('ScrollHeight', 0); //获得滚动条最大高度
MaxScrollWidth := htmldoc.body.getAttribute('ScrollWidth', 0);//获得滚动条最大宽度
Web.OleObject.Document.ParentWindow.ScrollBy(MaxScrollWidth, MaxScrollHeight ); //滚动到最右最下