#include "windowHandler.h" #include "jawt_md.h" #include JNIEXPORT jint JNICALL Java_windowHandler_getHWND (JNIEnv *env, jobject jobj, jobject jframe) { JAWT awt; JAWT_DrawingSurface* ds; JAWT_DrawingSurfaceInfo* dsi; JAWT_Win32DrawingSurfaceInfo* dsi_win; jint lock; awt.version = JAWT_VERSION_1_4; if (JAWT_GetAWT(env, &awt) == JNI_FALSE) { return 0; } ds = awt.GetDrawingSurface(env, jframe); if (ds == NULL) { return 0; } lock = ds->Lock(ds); if ((lock & JAWT_LOCK_ERROR) != 0) { awt.FreeDrawingSurface(ds); return 0; } dsi = ds->GetDrawingSurfaceInfo(ds); if (dsi == NULL) { ds->Unlock(ds); awt.FreeDrawingSurface(ds); return 0; } dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; HWND hWnd = dsi_win->hwnd; /* Free the drawing surface info */ ds->FreeDrawingSurfaceInfo(dsi); /* Unlock the drawing surface */ ds->Unlock(ds); /* Free the drawing surface */ awt.FreeDrawingSurface(ds); return (jint)hWnd; }