procedure TForm7.FlatButton2Click(Sender: TObject);
var tr: IHTMLTxtRange; r_,g_,b_ : Byte; val1:String; fnd:Boolean;
begin try
fnd:=false;
GetRGBValue(FlatColorComboBox1.Value,r_,g_,b_);
val1:=InttoHex(r_,2)+InttoHex(g_,2)+InttoHex(b_,2);
case form2.Notebook1.PageIndex of
0: tr := ((form2.wikipedia_console.Document as IHTMLDocument2).body as IHTMLBodyElement).createTextRange;
2: tr := ((form2.wikimedia_console.Document as IHTMLDocument2).body as IHTMLBodyElement).createTextRange;
3: tr := ((form2.wikidict_console.Document as IHTMLDocument2).body as IHTMLBodyElement).createTextRange;
5: tr := ((form2.wikibooks_console.Document as IHTMLDocument2).body as IHTMLBodyElement).createTextRange;
end;
while tr.findText(FlatEdit1.Text, 1, 0) do begin
fnd:=true;
tr.pasteHTML('<span style="background-color: #'+val1+'; font-weight: bolder;">' + tr.htmlText + '</span>');
tr.scrollIntoView(True);
end;
if not fnd then msgbox('Search and Highlight','Wikibrowse has finished searching the article, the search item was not found !',0,1);
Close;
except end;End; |