掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
WebBrowserで表示中の画面の文字列検索は? (ID:18634)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
>Microsoft ActiveX Data Objects 2.8Library 私のDelphi6 Personal(UP2)が入ったPC(on VMWare)は,Data Objectsは 入れていませんのであしからず. 今回インストールすべきは, [Microsoft HTML Object Library (Version4.0)] ですね.参考までに私がテストしたコードです. unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,mshtml_TLB, StdCtrls, OleCtrls, SHDocVw_TLB; type TForm1 = class(TForm) WebBrowser1: TWebBrowser; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private 宣言 } public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.dfm} procedure WBLocateHighlight(WB: TWebBrowser; Text: string) ; const prefix = '<span style="color:white; background-color: blue;">'; suffix = '</span>'; var tr: IHTMLTxtRange; begin if Assigned(WB.Document) then begin tr := ((wb.Document AS IHTMLDocument2).body AS IHTMLBodyElement).createTextRange; while tr.findText(Text, 1, 0) do begin tr.pasteHTML(prefix + tr.htmlText + suffix) ; tr.scrollIntoView(True) ; end; end; end; procedure TForm1.Button1Click(Sender: TObject); begin WebBrowser1.Navigate('https://www.petitmonte.com/bbs/answers?question_id=3405'); end; procedure TForm1.Button2Click(Sender: TObject); begin WBLocateHighlight(WebBrowser1,'武田'); end; end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.