Implementing Untyped Messages for unknown message types [message #850201] |
Thu, 19 April 2012 17:34  |
Eclipse User |
|
|
|
I am trying to implement a 3dconnexion spacenavigator in an SWT application. after creating a small jni (win32 only at the moment) stub I was expecting to be able to post messages to the main Shell window using the windows SendMessage command. Then using the following in the SWT application
int MY_MESSAGE = OS.RegisterWindowMessage(new TCHAR(0, "3dxEvent", true));
shell.addListener(MY_MESSAGE, new Listener() {
@Override
public void handleEvent(Event event) {
System.out.println("I cant beleive this worked");
}
});
Even posting a message from within the SWT application doesn't seem to work.
OS.SendMessageW(shell.handle, MY_MESSAGE, 0, 0);
Any ideas?
|
|
|
|
Re: Implementing Untyped Messages for unknown message types [message #856398 is a reply to message #850991] |
Wed, 25 April 2012 12:16  |
Eclipse User |
|
|
|
Hi Peter, this approach won't work. What you'll need to do:
- SWT subclasses the Windows proc. At the native level you'll have to
get and keep a handle to this subclass and then re-subclass the Windows
proc with your own Windows subclass.
- Your subclass will pass 99% of received messages (all those not from
your input device) to the stored swt subclass for normal processing.
- When a message is received from the input device then use JNI to
invoke a java method of yours.
HTH,
Grant
On 4/20/2012 10:38 AM, Peter Davis wrote:
> OK, I've looked at the code and it appears you can't uses messages like
> this :( SWT filters out unknown messages.
>
> So the question becomes "If we have a native window accepting messages
> from an input device how can we send these messages to an SWT window"?
|
|
|
Powered by
FUDForum. Page generated in 0.05179 seconds