On May 13, 2008, at 8:18 AM, Dale...@coats.com wrote:
I worked through many theories (ByteBuffer, WString,
Structure.ByValue,
Pointer, etc) but nothing I've tried got me very far with being able
to
supply a wchar_t into a Structure. I figure that one of the things
I've been trying will work if I just get some more implementation
details right.
'x' shows as the "tool tip" if I do this:
public static class NOTIFYICONDATA extends Structure {
public int cbSize;
public HANDLE hWnd; // HWND.setPointer(aJWindow) keeps XP happy,
btw!
public int uID;
public int uFlags;
public int uCallbackMessage;
public HANDLE hIcon;
public char szTip = 'x';
}
Since the native definition indicates:
TCHAR szTip[64]; // or 128, depending on some preprocessor constants
you need to use (assuming windows unicode flavor):
public char[] szTip = new char[SZ_TIP_SIZE]; // field initialization
is important to sizing the struct
Then use Native.toString(s.szTip) to convert back to Java String.
Don't assign szTip to a new array unless it's the same size as the
original; it's better to copy values in.