OleControlSite 吃关键事件

发布于 2024-11-26 03:05:46 字数 1250 浏览 2 评论 0原文

我正在开发一个包含视图的 Eclipse RCP 插件。此视图包含托管 Excel 工作簿的 OleControlSite。

Excel 工作簿被添加到视图中,其代码如下:

    public void createPartControl(Composite parent) {
        :
        OleFrame oleFrame = new OleFrame(parent, SWT.NONE);
        OleControlSite oleSite = new OleControlSite(frame, SWT.NONE, "Excel.Sheet");
        oleSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
        :
    }

我希望能够在 Excel 工作簿获得焦点时响应 Eclipse 键绑定。目的是弹出一个“帮助器”对话框,帮助用户为电子表格中当前选定的单元格选择适当的值。

我遇到的问题是,Excel 正在咀嚼关键事件(如您所料),但随后也将它们吞掉;他们从来没有进入 Eclipse 工作台,这样我就可以听到他们的消息。

在开发过程中,我通过 OLE 成功注册并收到了各种 Excel 活动。不过,我可以通过该机制处理的事件都是“Excel 特定的”事件,例如“工作表已激活”、“工作表已更改”、“工作表选择已更改”等。

:
String WORKBOOK_EVENT_SINK_ID   = "{00024412-0000-0000-C000-000000000046}";
int    WORKBOOK_SHEET_CHANGE_ID = 0x0000061c;

oleSite.addEventListener(controlSiteAuto, WORKBOOK_EVENT_SINK_ID, WORKBOOK_SHEET_CHANGE_ID, myListener);
:

似乎没有办法注册原始按键事件。

虽然吐槽了在 Excel 获得焦点时“听到”关键事件的可能方法,但我尝试向默认 Display、活动 Shell、视图本身等添加过滤器、侦听器和关键侦听器,但是毫无喜悦。感觉 Excel 在关键事件上绝对处于领先地位。

我开始考虑恶作剧的可能性,比如在 Excel 工作簿中注入一个宏,该宏会监视感兴趣的击键,并通过生成一个我可以注册的事件来响应OleControlSite。当我想到这些想法时,感觉也许我正在冒险超越良好的常识范围……

如果有人有任何想法,我会很高兴听到他们的想法。

I'm working on an Eclipse RCP plugin that contains a View. This View contains an OleControlSite that hosts an Excel workbook.

The Excel workbook is added to the view with code along the lines of:

    public void createPartControl(Composite parent) {
        :
        OleFrame oleFrame = new OleFrame(parent, SWT.NONE);
        OleControlSite oleSite = new OleControlSite(frame, SWT.NONE, "Excel.Sheet");
        oleSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
        :
    }

What I'd like to be able to do is respond to an Eclipse key binding while the Excel workbook has the focus. The intent is to pop up a "helper" dialog that assists the user in choosing an appropriate value for the currently selected cell in the spreadsheet.

The problem I've run into is that Excel is chewing up key events (as you'd expect), but is then swallowing them as well; they never make their way to the Eclipse workbench so that I can hear about them.

I'm successfully registered for and received a variety of Excel events, through OLE, over the course of development. The events I have at my disposal through that mechanism, though, are all "Excel-specific" things like "sheet activated," "sheet changed," "sheet selection changed," those sorts of things.

:
String WORKBOOK_EVENT_SINK_ID   = "{00024412-0000-0000-C000-000000000046}";
int    WORKBOOK_SHEET_CHANGE_ID = 0x0000061c;

oleSite.addEventListener(controlSiteAuto, WORKBOOK_EVENT_SINK_ID, WORKBOOK_SHEET_CHANGE_ID, myListener);
:

There doesn't seem to be a way to register for raw key events.

While spit-balling possible ways to "hear" key events while Excel has the focus, I've tried adding filters, listeners, and key listeners to things like the default Display, the active Shell, the View itself, and so on, but with no joy. It feels like Excel is getting absolute-first-crack at key events.

I'm starting to ponder the possibility of shenanigans, like injecting a macro into the Excel workbook that would keep an eye out for keystrokes of interest, and would respond by generating an event that I could register for through the OleControlSite. It feels like maybe I'm venturing beyond the realm of good common sense when I think thoughts like these...

If anyone has any notions, I'd be thrilled to hear about them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文