Java/SWT: How to receive mouse events from an embedded window

社会主义新天地 提交于 2019-12-08 08:52:28

问题


I am embedding a windows application into my SWT application using 'reparenting'. That part works ok. I would now like to hook my SWT app into the message queue for the embedded app to receive mouse move events.

I see that the OS class in SWT has a number of interesting methods for adding hooks but I have not been able to figure out how to use them.

Can anyone help?

Thanks


回答1:


This should work, but it relies on using reflection to call non-API, so use it at your own risk.

Use reflection to make Display.addControl() and Display.removeControl() accessible. Then, use it to add the HWND of the Windows application and the owning control to the Display object. Now, when a mouse move event is sent to the embedded app, the corresponding Control should get a mouse move event.

For good measure you should add a DisposeListener on the owning Control and call removeControl() so events won't get sent to the dead HWND.



来源:https://stackoverflow.com/questions/834771/java-swt-how-to-receive-mouse-events-from-an-embedded-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!