Click here to Skip to main content
16,019,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
}
Posted
Updated 31-Jul-11 20:29pm
v3
Comments
TorstenH. 1-Aug-11 2:29am    
added code tags

I have one question: What are you trying to achieve? Why do you mix C++ and Java?
 
Share this answer
 
Comments
Sumit K Sharma 1-Aug-11 3:50am    
Sir I have added a system menu "about" as i right click on the title bar the list of the menu is shown i have added my menu "about" on the click of that menu i need to open the box about box on the click on that menu.

I have added the menu in the list using c++ code because i am unable to do this using java
TorstenH. 1-Aug-11 5:42am    
not really!
http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html

BUY A BOOK! You need it. Books are better as you can browse through them without "entering" a keyword first.
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.
 
Share this answer
 
Comments
TorstenH. 1-Aug-11 6:48am    
he got no valid answer - might be the cause of a repost.
Sumit K Sharma 1-Aug-11 7:17am    
Thanks Sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900