I have a c application and a java application. I communicate with jna to get results from the c program. I Have a jna-Callback function:
public LRESULT callback(HWND hWnd, int uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WinUserConstants.WM_GRAB_BASE:
System.out.println("WM_GRAB_BASE");
return new LRESULT(1);
case WinUserConstants.WM_GRAB_TRANSFER_FINISHED:
System.out.println("WM_GRAB_TRANSFER_FINISHED");
return new LRESULT(1);
case WinUserConstants.WM_GRAB_IMAGE_SAVED:
System.out.println("WM_GRAB_IMAGE_SAVED");
return new LRESULT(1);
default:
return User32.INSTANCE.DefWindowProc(hWnd, uMsg, wParam, lParam);
}
I need the WPARAM variable. I cant change the WPARAM to String. If i do that my window shows no controls. WPARAM is defined as "HGLOBAL on memory containing (wchar_t *)filename". I need that filename and cant access the c code.
You can use WPARAM.toPointer().getWideString(0)
to extract the string.
toPointer()
effectively "casts" the WPARAM to a pointer value, from which you can then extract the (wide) native C string.