• C

Menus

OK.  This is probably the stupid question of the day, but I can't seem to find the answer.

I have created a form with a menu.  Everything is working properly, but I need to know what message is posted to the WindowProc when the menu is clicked.  For example, if someone clicks on File | Exit, and the ID of the exit menu is IDR_EXIT, what message gets posted to the WindowProc?
LVL 5
dirtdartAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alexoCommented:
WM_COMMAND.

PS.  This is a "Windows" question, not a "C" question
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alexoCommented:
The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.

WM_COMMAND :

wNotifyCode = HIWORD(wParam); // notification code
wID = LOWORD(wParam);         // item, control, or accelerator identifier
hwndCtl = (HWND) lParam;      // handle of control
 
Parameters:

wNotifyCode - Value of the high-order word of wParam. Specifies the notification code if the message is from a control. If the message is from an accelerator, this parameter is 1. If the message is from a menu, this parameter is 0.

wID - Value of the low-order word of wParam. Specifies the identifier of the menu item, control, or accelerator.

hwndCtl - Value of lParam. Identifies the control sending the message if the message is from a control. Otherwise, this parameter is NULL.
 
Return Values - If an application processes this message, it should return zero.

Remarks:

Accelerator keystrokes that select items from the window menu are translated into WM_SYSCOMMAND messages.

If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized, no WM_COMMAND message is sent. However, if an accelerator keystroke occurs that does not match any of the items in the window's menu or in the window menu, a WM_COMMAND message is sent, even if the window is minimized.

If an application enables a menu separator, the system sends a WM_COMMAND message with the low-word of the wParam parameter set to zero when the user selects the separator.

0
alexoCommented:
There are no stupid questions.  Only stupid answers.
0
dirtdartAuthor Commented:
Well, that's what I thought in the first place.  I guess I must have typed something wrong the first time I tried it with WM_COMMAND, cause it didn't work then, but it does now.  Well, live and learn.  I just wish Microsoft would include more documentation on Win32 and not just MFC.  I personally think MFC bites and try to avoid it at every possible opportunity.

Thanks for the help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.