【发布时间】:2016-10-14 18:26:58
【问题描述】:
我正在尝试使用 Delphi 2010 在网络浏览器中查找文本并滚动到其中。代码找到文本并滚动到它,但文本停留在 webview 的底部(在最后一行)。我想在 webview 的顶部(第一行)显示文本。
我认为此代码将是“scrollIntoView(true)”,但它根本不影响我正在尝试做的事情。
我该怎么办?谢谢。这是我的代码
procedure TForm1.SpeedButton10Click(Sender: TObject);
var
doc: IHTMLDocument2;
selection: IHTMLSelectionObject;
textRange: IHtmlTxtRange;
scrollpos: Integer;
Art : string;
begin
Doc := WebBrowser1.Document as IHTMLDocument2;
Selection := Doc.Selection;
TextRange := selection.createRange as IHTMLTxtRange;
Art := edit2.Text;
TextRange.collapse(false);
if TextRange.findText(Art) then
begin
TextRange.select;
TextRange.scrollIntoView(true);
end;
end;
【问题讨论】:
标签: delphi scroll twebbrowser