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

I am embedding windows app in my SWT app using "reparenting". This part works fine. Now I would like to connect my SWT application to a message queue for an embedded application 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 please help?

thanks

+1


a source to share


1 answer


This should work, but it uses reflection to make non-API calls, so use it at your own risk.

Use reflection to make Display.addControl () and Display.removeControl () available. Then use it to add the Windows application HWND and control to the Display object. Now, when a mouse move event is dispatched to an embedded application, the corresponding control should receive a mouse move event.



For good measure, you should add a DisposeListener to the control and call removeControl () so that no events are dispatched to the dead HWND.

+2


a source







All Articles