I don know how to send a message to menu where the menu is locate outside of my application.. It is totally out of my control... So I decide to use SendMessage() to control that menu...
So I am having trouble in the syntax, what should I pass in for the 3rd and 4th parameter? I have done the SendMessage() in this way:
Code:
SendMessage(hWnd, WM_COMMAND, x, y)
Am I doing the right way? Please inform me if the above code is not correct..
I don know how to send a message to menu where the menu is locate outside of my application.. It is totally out of my control... So I decide to use SendMessage() to control that menu...
So I am having trouble in the syntax, what should I pass in for the 3rd and 4th parameter? I have done the SendMessage() in this way:
Code:
SendMessage(hWnd, WM_COMMAND, x, y)
Am I doing the right way? Please inform me if the above code is not correct..
THank YOu @!
see attached. 2 solution are explained there:
1. using PostMessage
2. using EnableMenuItem
Your code really make me feel suprise... THank YOu!! But why don you use SendMessage()? Hmm~ Basically I want to select or click on the menu, not make it gray... And have a question, your code is to make the "NEW" menu become gray, and then when I run the exe, it make the "NEW" and "OPEN" menu become gray? Can you explain why this happen? THank YOu @!
To VictorN:
Hmm~ For example here, I have a VB program with menu, and then I have a C++ program with button... And from C++ program, I click on the C++ program's button, it will then hit on the VB's menu... just that the way... Can I do that using SendMessage()?
Or do you think Alin's idea is good? I mean he is using PostMessage() instead of SendMessage()... Which 1 better?
do you think Alin's idea is good? I mean he is using PostMessage() instead of SendMessage()... Which 1 better?
It is very dangerous to SendMessage to other application/other thread: you could get into a serious deadlock situation! Your app will wait for the reply from another one and nobody knows how long it can last
Your code really make me feel suprise... THank YOu!! But why don you use SendMessage()? Hmm~ Basically I want to select or click on the menu, not make it gray... And have a question, your code is to make the "NEW" menu become gray, and then when I run the exe, it make the "NEW" and "OPEN" menu become gray? Can you explain why this happen? THank YOu @!
as i alreadytold you i provided you with 2 different methods to gray/check a menu item. you're the on to decide which one fits you best.
About ::SendMessage, what VictorN said makes perfect sense.
as i alreadytold you i provided you with 2 different methods to gray/check a menu item. you're the on to decide which one fits you best.
yup! I just notice yesterday... sorry..
It is very dangerous to SendMessage to other application/other thread: you could get into a serious deadlock situation! Your app will wait for the reply from another one and nobody knows how long it can last
OIC ... now I understand... Hmmm~ Does this the only case that not suitable for SendMessage()?
And then this haven solve my problem, how to make it click on the menu..?
EnumWindows(EnumBFEWindows, MYWINDOW); // this will return the my window's handle to g_hWnd..
hMenu = GetMenu(g_hWnd); // from the hWnd I get the menu handle...
nMenuID = GetMenuItemID(hMenu, 6); // get the menu id from the menu handle.. 6 is the position of the menu which I use to click on...
SendMessage(hwndWinView, WM_COMMAND, nMenuID, NULL); // hit the menu...
Thats all I done...
But how can I SendMessage() to hit the button?
THank YOu @!
Last edited by huahsin68; June 24th, 2004 at 10:30 PM.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.