1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| JNIEXPORT jint findWindowFromJava(JNIEnv, jobject, jstring classname, jstring windowsname){
return (jint)findWindow(classname, windowsname); //renvoie le handle de la fenetre
}
JNIEXPORT jboolean JNICALL init(JNIEnv, jobject, jlong hWnd){ //hWnd est le handle de la fenetre (recuperer dans ma classe java, puis réinjecter ici (...))
HINSTANCE hInst = (HINSTANCE)GetWindowLong((HWND)hWnd, GWL_HINSTANCE); // recupere l instance de la fenetre grace au handle
MyRegisterClass(hInst);
//Enable all gesture types
GESTURECONFIG gestureConfig;
gestureConfig.dwID = 0;
gestureConfig.dwBlock = 0;
gestureConfig.dwWant = GC_ALLGESTURES; // Permet tous les gestes
BOOL result = SetGestureConfig((HWND)hWnd, 0, 1, &gestureConfig, sizeof(gestureConfig));
if (!result){
return FALSE;
}else{
return TRUE;
}
}
ATOM MyRegisterClass(HINSTANCE hInstance) //class recopiee d un projet fonctionnant
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = L"SunAwtFrame"; // mis en brut pour l instant
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
return RegisterClassEx(&wcex);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
cout << "Je rentre dans WndProc" << endl;
switch (message)
{
break;
case WM_GESTURE:
return ProcessGestureMessage(hWnd, wParam, lParam); // une fonction non necessaire de montrer
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return0;
} |
Partager