CMenu Class
An encapsulation of the Windows HMENU.
class CMenu : public CObject
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CMenu object. |
Public Methods
Name |
Description |
---|---|
Appends a new item to the end of this menu. |
|
Attaches a Windows menu handle to a CMenu object. |
|
Places a check mark next to or removes a check mark from a menu item in the pop-up menu. |
|
Places a radio button next to a menu item and removes the radio button from all of the other menu items in the group. |
|
Creates an empty menu and attaches it to a CMenu object. |
|
Creates an empty pop-up menu and attaches it to a CMenu object. |
|
Deletes a specified item from the menu. If the menu item has an associated pop-up menu, destroys the handle to the pop-up menu and frees the memory used by it. |
|
Deletes any temporary CMenu objects created by the FromHandle member function. |
|
Destroys the menu attached to a CMenu object and frees any memory that the menu occupied. |
|
Detaches a Windows menu handle from a CMenu object and returns the handle. |
|
Called by the framework when a visual aspect of an owner-drawn menu changes. |
|
Enables, disables, or dims (grays) a menu item. |
|
Returns a pointer to a CMenu object given a Windows menu handle. |
|
Determines the default menu item on the specified menu. |
|
Retrieves the help context ID associated with the menu. |
|
Retrieves information on a specific menu. |
|
Determines the number of items in a pop-up or top-level menu. |
|
Obtains the menu-item identifier for a menu item located at the specified position. |
|
Retrieves information about a menu item. |
|
Returns the status of the specified menu item or the number of items in a pop-up menu. |
|
Retrieves the label of the specified menu item. |
|
Returns the m_hMenu wrapped by this CMenu object. |
|
Retrieves a pointer to a pop-up menu. |
|
Inserts a new menu item at the specified position, moving other items down the menu. |
|
Inserts a new menu item at the specified position in a menu. |
|
Loads a menu resource from the executable file and attaches it to a CMenu object. |
|
Loads a menu from a menu template in memory and attaches it to a CMenu object. |
|
Called by the framework to determine menu dimensions when an owner-drawn menu is created. |
|
Changes an existing menu item at the specified position. |
|
Deletes a menu item with an associated pop-up menu from the specified menu. |
|
Sets the default menu item for the specified menu. |
|
Sets the help context ID to be associated with the menu. |
|
Sets information on a specific menu. |
|
Associates the specified check-mark bitmaps with a menu item. |
|
Changes information about a menu item. |
|
Displays a floating pop-up menu at the specified location and tracks the selection of items on the pop-up menu. |
|
Displays a floating pop-up menu at the specified location and tracks the selection of items on the pop-up menu. |
Public Operators
Name |
Description |
---|---|
Retrieves the handle of the menu object. |
|
Determines if two menu objects are not equal. |
|
Determines if two menu objects are equal. |
Public Data Members
Name |
Description |
---|---|
Specifies the handle to the Windows menu attached to the CMenu object. |
Remarks
It provides member functions for creating, tracking, updating, and destroying a menu.
Create a CMenu object on the stack frame as a local, then call CMenu's member functions to manipulate the new menu as needed. Next, call CWnd::SetMenu to set the menu to a window, followed immediately by a call to the CMenu object's Detach member function. The CWnd::SetMenu member function sets the window's menu to the new menu, causes the window to be redrawn to reflect the menu change, and also passes ownership of the menu to the window. The call to Detach detaches the HMENU from the CMenu object, so that when the local CMenu variable passes out of scope, the CMenu object destructor does not attempt to destroy a menu it no longer owns. The menu itself is automatically destroyed when the window is destroyed.
You can use the LoadMenuIndirect member function to create a menu from a template in memory, but a menu created from a resource by a call to LoadMenu is more easily maintained, and the menu resource itself can be created and modified by the menu editor.
Inheritance Hierarchy
CMenu
Requirements
Header: afxwin.h