TWEBBROWSER control connection to the MSHTML library

zhaozj2021-02-08  263

WebBrowser control configuration is the same as IE configuration

Method One Use the Document property to get the Document layer webbrowser.document: idispatch // is the IDispatch interface

VAR DOC: IHTMLDocument2; Begin ... TRY // Note: Try ... Except ... END protection DOC: = (WebBrowser1.document) as htmldocument2; if assigned (doc) THEN BEGIN / / JR Whether it is empty ... // End; ExcePt ... end; ... End;

Method 2 Use the queryinterface interface to get the Window layer webbrowser.queryinterface (IID_IHTMLWindow2, Out Win: IHTMLWindow2); / / Return to the IHTMLWindow2 interface of the WebBrowser control

Var Win: IHTMLWindow2; Begin ... trywebbrowser1.queryinterface (IID_IHTMLWindow2, win); if Assigned (win) THEN BEGIN / / JRIST is empty ... // Concrete operation End; ExcePt ... End; ... END;

转载请注明原文地址:https://www.9cbs.com/read-1055.html

New Post(0)