使用Java的系统菜单 [英] System menu using java

查看:84
本文介绍了使用Java的系统菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生
我在系统菜单中添加了一个菜单项,并使用jni使用c ++代码,我想在单击该菜单时显示一个对话框.我的代码如下
DLL代码-

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 ...");
				
			 }
}


我在c ++ dll中使用了以下功能,但如果有人可以帮助我,它就不再担心,然后请尽快给我解决方案
提前谢谢...


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
}

推荐答案

我有一个问题:您要实现什么目标?为什么要混合使用C ++和Java?
I have one question: What are you trying to achieve? Why do you mix C++ and Java?


这是^ ];请不要重新发布相同的查询,您已经得到了建议.但是,我也想问一下,为什么要在Java中使用C ++来实现这样的基本功能.
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.


这篇关于使用Java的系统菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆