Monday, 15 April 2013

How to attach an event to IHTMLDocument2 link elements in Delphi? -


I am using this code to get all links from IHTMLDocument2:

  Process DoDocumentComplete (CONSTIPIPP: IDISPH; var URL: OLE Variant); Var Document: IHTMLDocument2; Body: IHTMLElement; Link: IHTMLElementCollection; I: integer; Tmp: IHTMLElement; Start Try Document: = (PDISP as IWebbrowser2). Document IHTMLDocument2; Body: = Document Link: = Document.links; I: Start (Links.length-1) from = tmp: = (Links.item (i, 0) as iHTMLElement); //tmp.onclick: How do I add callback? //ShowMessage (tmp.innerText); End; Apart from E: Exception Show Message (E. ClassName + 'has been raised with error message:' + E. Message); End; End;  

How can I add a function / process? Click to do a simple task, such as when a link is clicked, show an alert with anchor text?

One way is to sync events from TWebBrowser with an object that uses IDispatch (such as )

You

  tmp.onclick: IDIspatch will set = TEventObject.Create (callback processor);  

No comments:

Post a Comment