Sir
I have added a menu item in system menu and using c++ code using jni and i want to show a dialog box on the click of that menu My code is as follows
DLL Code-JNIEXPORT void JNICALL Java_native1_NativeAdd_add
(JNIEnv *env, jclass cls)
{
hwnd=FindWindowA(NULL,(LPCSTR)"Anand");
a=(int)hwnd;
printf("a=%d",a);
//printf("%d",hwnd);
HMENU sysmenu= ::GetSystemMenu(hwnd,false);
//printf("%d",sysmenu);
if(sysmenu)
{
::InsertMenuA(sysmenu,7,MF_BYPOSITION | MF_STRING,1001,"About ...");
}
}
I used the following function in c++ dll but it is not worrking any more if any one can help me then please give me the solution asap
Thanks in advance...
LRESULT CALLBACK WindowProcedure (HWND hwnd, //Handle to the window for this function
unsigned int uiMsg, //The message
WPARAM wParam, //Basically another part of the message
LPARAM lParam) //Basically another part of the message
{
printf("inside window");
switch (uiMsg) //All messages are int. So we can use a switch statement to handle them.
{
//case WM_CLOSE: //WM_CLOSE is defined as a int, this message is sent to our window procedure function when we go to close the window
//DestroyWindow (hwnd); //Send a WM_DESTROY message to the message queue for the hWnd handle.
The message queue is a place where messages go and wait to be sent to this function (From the DispatchMessage(&uMsg) funcion)
//break;
//case WM_DESTROY: //This will be used it WM_DESTROY is our message
//PostQuitMessage (0); //Send WM_QUIT to the message queue, this will break out message loop and then exit the application
//break;
case WM_SYSCOMMAND:
flag=true;
printf("%d",flag);
break;
case WM_KEYDOWN: //This is used if we press a key
switch (LOWORD (wParam)) //The actual key is in the lower 16bits of the wParam, so we need to do this
{
case VK_RETURN: //If we pressed the Enter/Return key
//MessageBox (hWnd, "The Enter/Return key was pressed", "Message:", MB_OK);
break;
case VK_TAB: //If we pressed the tab key
//MessageBox(hWnd, "The Tab key was pressed", "Message", MB_OK);
printf("sir");
break;
case 1001:
flag=true;
break;
}
break;
}
return DefWindowProc (hwnd, uiMsg, wParam, lParam); //Handle all the messages that we didn''t
}
解决方案
I have one question: What are you trying to achieve? Why do you mix C++ and Java?
This is a duplicate of this question[^]; please don''t repost the same query, you have already been given a suggestion. However, I would also ask why you are using C++ inside Java for something as basic as this.