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 9, 2008 1:13:53 pm
List:net.java.dev.jna.users

I would like to implement a callback so that my Java app can have a System Tray Icon on Windows.

ExtractIcon, NOTIFYICONDATA, Shell_NotifyIcon and DestroyIcon have been employed through JNA and those seem to be working; the system tray icon shows and is later destroyed. During the test, the callback handle is "empty", so moving the mouse to the icon causes Windows to delete it. So I need to make a "real" callback handler.

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....

User32.WM_MOUSEMOVE wmMouseMove = new User32.WM_MOUSEMOVE() { public boolean MouseMove(HWND hwnd, int uMsg, int wParam, int lParam) { System.out.println("callback " + hwnd); return false; } };

Thread listener = new Thread("Mouse Move Listener") { public void run() { System.out.println("In the mouse move listener run method."); // Call some native thing here that returns a handle // Should it also block? } }; listener.start();

Am I getting anywhere close? Thanks for having a look.

--Dale--

I have added the following to User32.java:

public static interface WM_MOUSEMOVE extends com.sun.jna.win32.StdCallLibrary.StdCallCallback { public abstract boolean MouseMove(HWND hwnd, int uMsg, int wParam, int lParam); /* *LRESULT CALLBACK MouseMove( * HWND hwnd, [in] Handle to the window. * UINT uMsg, [in] Specifies the message. * WPARAM wParam, [in] Specifies additional message information. * LPARAM lParam [in] Specifies additional message information. *); *The return value is the result of the message processing and depends on the message sent. */ // TODO: figure out if wParam and lParam are really int }

WindowProc Function http://msdn.microsoft.com/en-us/library/ms633573(VS.85).aspx NOTIFYICONDATA http://msdn.microsoft.com/en-us/library/bb773352%28VS.85%29.aspx