4 messages in net.java.dev.jna.usersStructuring of a Callback on Windows ...
FromSent OnAttachments
Dale...@coats.comMay 9, 2008 1:13 pm 
Timothy WallMay 9, 2008 1:25 pm 
Dale...@coats.comMay 11, 2008 1:58 pm 
Timothy WallMay 11, 2008 4:44 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Structuring of a Callback on Windows User32Actions...
From:Dale...@coats.com (Dale@coats.com)
Date:May 11, 2008 1:58:55 pm
List:net.java.dev.jna.users

So to recap, I can create an tray icon fine. But so far with just an 'empty' window handle. When the OS realizes there's nobody to send messages to, it deletes the icon (as soon as you move your mouse to the icon). So I need to start a thread (I suppose) that has a window handle that I can give to the Shell_NotifyIcon so that the OS can use it when the mouse pointer is moved to the icon.

In the EnumWindows example, the OS didn't need a handle because we passed the object that had implemented the callback right into the EnumWindows method; it knew which object to run the callback on. In my the Shell_NotifyIcon example, the icon itself (NOTIFYICONDATA structure) knows which objects callback method to use only through the window handle that it has.

On Fri, 09 May 2008 16:26:12 -0400, Timothy Wall wrote:

On May 9, 2008, at 4:14 PM, Dale@coats.com wrote:

// TODO: figure out if wParam and lParam are really int

LPARAM and WPARAM are defined in JNA's W32API class.

Thanks. That was something I should have seen.

Structuring the callback is a puzzle for me. I do not know how to proceed, re:"Call some native thing here", below, in the code....

(snip)

Callbacks have a single method, which must be named "callback". So rename your interface method "MouseMove" to "callback", and things should work.

I renamed the method, but that didn't do it. I think I'm missing a window handle, and I don't know how to get it. Starting a Java thread is not the answer (no native handle).

It seems to me that first I need to start some kind of "native thread" that has a window handle. This thread would have the callback method in it. Then I take that handle and use it when I create my Shell_NotifyIcon. Shell_NotifyIcon "knows" not only about what icon I want in the tray, but also the handle of the window that the OS will send events to.

Is this possible with JNA?

--Dale--