我的 ActiveX 控件如何接管 Internet Explorer 中的打印、另存为、查找等功能?
我有一个 ActiveX 控件,可以在 IE 中显示给定文件格式的文档,就像 Adobe 有一个显示 PDF 的 ActiveX 控件一样。
我的控件是一个全页控件,就像 PDF 查看器一样 - 它接管 IE 的整个客户端区域,使用 IE 自己的 启用FullPage机制。
我想控制与文档相关的各种菜单和工具栏命令:打印、打印预览、页面设置、另存为、全选、复制、查找等。我猜一定有一个官方 API 可以做到这一点,因为 PDF 查看器就是这样做的。 (请注意,打印嵌入式 ActiveX 控件等标准机制不适用 - 我需要显示自己的打印对话框并控制整个过程,就像 PDF 查看器一样。)
(之前IE8 我可以通过使用 Win32 子类化来侵入 IE 本身,这很讨厌但有效,但是 IE8 将选项卡内容保留在与工具栏不同的进程中,因此这不是没有 DLL 注入的选项,我可以看到。 Adobe PDF veiwer 没有这样做,这就是为什么我相信有一个官方机制。)
I have an ActiveX control that displays documents of a given file format within IE, much like Adobe have an ActiveX control that displays PDFs.
My control is a full-page control, just like the PDF viewer - it takes over the whole client area of IE, using IE's own EnableFullPage mechanism.
I'd like to take control of the various menu and toolbar commands that pertain to the document: Print, Print Preview, Page Setup, Save As, Select All, Copy, Find, and so on. I'm guessing there must be an official API for doing this, because the PDF viewer does it. (Note that the standard mechanisms for eg. printing embedded ActiveX controls don't apply - I need to show my own Print dialog and control the whole process, just like the PDF viewer does.)
(Prior to IE8 I was able to do it by using Win32 subclassing to hack into IE itself, which is nasty but works. But IE8 keeps the tab contents in a different process from the toolbar, so that's not an option without DLL injection, and I can see that the Adobe PDF veiwer isn't doing that. That's why I believe there's an official mechanism.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能是与 DocObjects 相关的接口,可能是 IOleInPlaceFrame + IOleCommandTarget
Probably some interface related to DocObjects, maybe IOleInPlaceFrame + IOleCommandTarget
您可以使用 ActiveDoc 示例作为实现活动文档的基础服务器按照安德斯的建议。正如他还指出的那样,添加 IOleCommandTarget 可以让您控制菜单项。
You may use the ActiveDoc sample as a base for implementing an active document server as Anders suggested. Adding IOleCommandTarget, as he also noted, gives you control over the menu items.