Solved

Menus

Posted on 1998-04-22
4
238 Views
Last Modified: 2012-05-04
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?
0
Comment
Question by:dirtdart
  • 3
4 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 100 total points
ID: 1251493
WM_COMMAND.

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

Expert Comment

by:alexo
ID: 1251494
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
 
LVL 11

Expert Comment

by:alexo
ID: 1251495
There are no stupid questions.  Only stupid answers.
0
 
LVL 5

Author Comment

by:dirtdart
ID: 1251496
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

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
memory mapped I/O query 6 147
How to get time_t value that is a week old 6 168
Why adding test code changes the build ? 11 132
Want to delete all my personal data 13 145
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question