Solved

Menus

Posted on 1998-04-22
4
242 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

860 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