About the author
After weeks of no coding, I'm back on my feet again, doing some coding again... My quest this time: To loop through all the frames in a TWebBrowser.
Here's how to get the code below to find all the frames (regardless of level of nesting) in a TWebBrowser: FindFrame(WebBrowser1.Document);
procedure FindFrame(ADocument: IHTMLDocument2);var LDocument: IHTMLDocument2; LContainer: IOleContainer; LEnumerator: IEnumUnknown; LUnknown: IUnknown; LFetched: Longint; LBrowser: IWebBrowser2; LResult: HRESULT;begin if not Supports(ADocument, IOleContainer, LContainer) then exit; if not Succeeded(LContainer.EnumObjects(OLECONTF_EMBEDDINGS, LEnumerator)) then exit; while LEnumerator.Next(1, LUnknown, @LFetched)=S_OK do begin if Supports(LUnknown, IID_IWebBrowser2, LBrowser) then begin // Is a frame if Supports(LBrowser.Document, IID_IHTMLDocument2, LDocument) then begin Memo1.Lines.Add(LDocument.title); FindFrame(LDocument); LDocument := nil; end; LBrowser := nil; end; LUnknown := nil; end; LEnumerator := nil; LContainer := nil;end;
Continued discussion of undocumented Delphi 8 Property Access Specifiers, and other ways of adding and removing delegates / events handlers, including clearing the list of all the delegates / event handlers.