java 菜单系统,使用java的系统菜单

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值