如何获取Internet Explorer提供的原始IDocHostUIHandler?
在IDocHostUIHandler 接口的文档 ,在谈论使用 BHO 中的 ICustomDoc 导致的内存泄漏时,有一段关于 IE 提供的默认 UI 处理程序:
To avoid a memory leak:
1. Always forward the IDocHostUIHandler::ShowUI and
IDocHostUIHandler::HideUI methods to the original handler.
2. Release the pointer to the original UI handler when your object is called
with IObjectWithSite::SetSite(NULL).
如何获取主机接口以释放它?
In the documentation of the IDocHostUIHandler Interface, there is a paragraph about the default UI handler provided by IE when talking about a memory leak caused by using ICustomDoc from a BHO:
To avoid a memory leak:
1. Always forward the IDocHostUIHandler::ShowUI and
IDocHostUIHandler::HideUI methods to the original handler.
2. Release the pointer to the original UI handler when your object is called
with IObjectWithSite::SetSite(NULL).
How to get the host interface in order to release it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然不受官方支持,但您仍然可以获得对原始
IDocHostUIHandler
的引用,以便传递对您不打算在 BHO 中覆盖的所有方法的调用。首先,将文档转换为
IOleObject
,然后调用GetClientSite
以获取原始IOleClientSite
对象。然后可以将其转换为IDocHostUIHandler
或IOleCommandTarget
,以便从原始处理程序/目标上的这些接口调用方法。下面是来自 C# BHO 的 DocumentComplete 事件的示例代码片段(
Explorer
是ShDocVw.WebBrowserClass
的实例,UIHandler
是我自己的< code>IDocHostUIHandler 类,它将调用传递给初始化程序中传递的对象,所有接口均直接取自 http://pinvoke.net):这是根据 PopupBlocker 项目中的 C++ 代码改编的,此处提供 http://www.codeproject.com/Articles/4003/Popup-Window-Blocker
While not officially supported, you can still get a reference to the original
IDocHostUIHandler
in order to pass calls through on all of the methods you don't plan on overriding in your BHO.First you cast the document as an
IOleObject
and then callGetClientSite
in order to obtain the originalIOleClientSite
object. This can then be cast to eitherIDocHostUIHandler
orIOleCommandTarget
in order to call the methods from those interfaces on the original handler/target.Here is an example code snippet from the DocumentComplete event of a C# BHO (
Explorer
is an instance ofShDocVw.WebBrowserClass
,UIHandler
is my ownIDocHostUIHandler
class which passes calls through to the object passed in the initializer, and all of the interfaces were taken directly from http://pinvoke.net):This was adapted from C++ code available in the PopupBlocker project available here http://www.codeproject.com/Articles/4003/Popup-Window-Blocker
如今整段文字如下:
所以它根本不支持你想要做的事情(至少官方)。
The whole passage nowadays reads
So it is simply not supported what you are trying to do (at least officially).