Solved

Menus

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now