I have to force an existing JavaFX application to be "always in background", but I wasn't able to find that functionality natively in JavaFX (only always on top exists), hence I thought to use the Win32 API from an external JNI DLL to call the SetWindowPos() function.
I was able to link Java to C++, but I don't know how to get the native window handle (HWND) required by the function from the Java environment.
My sample call (from within the DLL):
#define X0 0
#define Y0 0
#define W 1920
#define H 1080
#define FLAGS 0
#define ALWAYS_ON_BOTTOM HWND_BOTTOM
#define I_DONT_KNOW_WHAT nullptr
JNIEXPORT void JNICALL Java_libreria_WindowsHandlerWrapper_SetAlwaysOnBottom
(JNIEnv* env, jobject obj) {
HWND hWnd = I_DONT_KNOW_WHAT; /* here is where I need help*/
SetWindowPos(
hWnd,
ALWAYS_ON_BOTTOM,
X0,
Y0,
W,
H,
FLAGS
);
}
What I don't know is how to get the hWnd handle.