Partager via


CWnd::OnMenuChar

The framework calls this member function when the user presses a menu mnemonic character that doesn't match any of the predefined mnemonics in the current menu.

afx_msg LRESULT OnMenuChar( 
   UINT nChar, 
   UINT nFlags, 
   CMenu* pMenu  
);

Parameters

  • nChar
    Depending on the build settings, specifies the ANSI or Unicode character that the user pressed.

  • nFlags
    Contains the MF_POPUP flag if the menu is a pop-up menu. It contains the MF_SYSMENU flag if the menu is a Control menu.

  • pMenu
    Contains a pointer to the selected CMenu. The pointer may be temporary and should not be stored.

Return Value

The high-order word of the return value should contain one of the following command codes:

Value

Description

0

Tells Windows to discard the character that the user pressed and creates a short beep on the system speaker.

1

Tells Windows to close the current menu.

2

Informs Windows that the low-order word of the return value contains the item number for a specific item. This item is selected by Windows.

The low-order word is ignored if the high-order word contains 0 or 1. Applications should process this message when accelerator (shortcut) keys are used to select bitmaps placed in a menu.

Remarks

It is sent to the CWnd that owns the menu. OnMenuChar is also called when the user presses ALT and any other key, even if the key does not correspond to a mnemonic character. In this case, pMenu points to the menu owned by the CWnd, and nFlags is 0.

Note

This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.

Requirements

Header: afxwin.h

See Also

Reference

CWnd Class

Hierarchy Chart

CWnd::OnMenuChar