hi,
public class DLLWrapper
{
private static class RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
public native boolean getClientRect(int hWnd, RECT rect);
public static void main(String args[]) // lets assume that args[1] is int pointer to parent window (say, in the screensaver's preview mode)
{
RECT rect = new RECT();
if(new DLLWrapper().getClientRect(Integer.parseInt(args[1]), rect))
{
// blah....
}
}
}
i compiled the above and generated DLLWrapper.h. then i added this to Win32DLLWrapper.h in my mfc appwizard (dll) project:
JNIEXPORT jboolean JNICALL Java_dll_DLLWrapper_getClientRect(JNIEnv *env, jobject obj1, jint hWnd, jobject obj2)
{
return GetClientRect((HWND) hWnd, (tagRECT*) obj2); //=======================> correct???
}
i then copied Win32DLLWrapper.dll to \system32 and i was able to run but didn't have a valid hwnd, which is fine
since i'm interested in the correctness of the code.
1. is everything correct thus far (can't test it with a valid hwnd)???
2. how do you translate the following c# code into java: Graphics g = Graphics.FromHwnd(hwnd);???
for question 2, do i add GetDC() in Win32DLLWrapper.h? the return type of GetDC() is HDC, can this be somehow converted into a java Graphics object???
please provide an example.
thank you very much!