如何在Delphi中查找IHTMLDocument2是否等于IDispatch文档?
我有一个带有iFrame的TEmbeddedWB(
https://sourceforge.net/projects/embeddedwb/).我必须找出特定的HTML标签是否在iFrame内部.我的iFrame对象是IHTMLFrameBase2,而Tag是IHTMLElement.我知道iFrame.contentWindow.document(它是一个IHTMLDocument2)与Tag.document相同.但Tag.document是一个IDispatch对象,因此下面给出了一个false:
if iFrame.contentWindow.document = Tag.document then ShowMessage('In iFrame') else ShowMessage('Not in iFrame'); 我知道这两个对象是一样的,因为Watch List可以显示它们的内存地址: 但是我无法从代码中获取他们的地址.我尝试过的: Addr(iFrame.contentWindow.document) // Gives variable required error @iFrame.contentWindow.document // Gives variable required error Pointer(iFrame.contentWindow.document) //Compiles,but gives wrong address Format('%p',[iFrame.contentWindow.document]) //Compiles,but gives EConvertError 注意:如果我逐行运行监视列表显示的地址在每行代码后都会发生变化,无论代码是否影响WebBrowser. 解决方法
从
rules of COM:
所以,问他们两个IUnknown接口,并进行比较. var disp: IDispatch; doc: IHTMLDocument2; .... if (disp as IUnknown) = (doc as IUnknown) then .... (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |