Posted by webmaster Guido on April 06, 2004
In Reply to: 'Text search' with TWebBrowser posted by Giovanni Caramia p12316
on April 06, 2004 The easiest is to use Windows' own Find dialog for the browser :) Example: the code below shows how clicking Button1 opens the browser Find dialog, and that works exactly like you are used to in your IE browser. Important: add "ACTIVEX" to the "uses" clause of your unit. procedure TForm1.Button1Click(Sender: TObject);
begin
// Replace WebBrowser1 with name of
// your webbrowser: WB1, MyBrowser or whatever
OpenFindDialog(WebBrowser1);
end;
procedure TForm1.OpenFindDialog(WB: TWebBrowser); const CGID_WebBrowser: TGUID = '{ED016940-BD5B-11cf-BA4E-00C04FD70816}'; HTMLID_FIND = 1; var CmdTarget : IOleCommandTarget; vaIn, vaOut: OleVariant; PtrGUID: PGUID; begin New(PtrGUID); PtrGUID^ := CGID_WebBrowser; if WB.Document <> nil then try WB.Document.QueryInterface(IOleCommandTarget, CmdTarget); if CmdTarget <> nil then try CmdTarget.Exec(PtrGUID, HTMLID_FIND, 0, vaIn, vaOut); finally CmdTarget._Release; end; except end; Dispose(PtrGUID); end;
[ DelphiLand: free Delphi source code, tips, tutorials ] |