Menus (Menus and Other Resources)

April 11, 2025 ยท View on GitHub

This section describes menus and explains how to use them.

In This Section

NameDescription
About MenusDiscusses menus.
Using MenusProvides code examples of tasks related to menus.
Menu ReferenceContains the API reference.
NameDescription
AppendMenuAppends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. You can use this function to specify the content, appearance, and behavior of the menu item.
CheckMenuItemSets the state of the specified menu item's check-mark attribute to either selected or clear.
CheckMenuRadioItemChecks a specified menu item and makes it a radio item. At the same time, the function clears all other menu items in the associated group and clears the radio-item type flag for those items.
CreateMenuCreates a menu. The menu is initially empty, but it can be filled with menu items by using the InsertMenuItem, AppendMenu, and InsertMenu functions.
CreatePopupMenuCreates a drop-down menu, submenu, or shortcut menu. The menu is initially empty. You can insert or append menu items by using the InsertMenuItem function. You can also use the InsertMenu function to insert menu items and the AppendMenu function to append menu items.
DeleteMenuDeletes an item from the specified menu. If the menu item opens a menu or submenu, this function destroys the handle to the menu or submenu and frees the memory used by the menu or submenu.
DestroyMenuDestroys the specified menu and frees any memory that the menu occupies.
DrawMenuBarRedraws the menu bar of the specified window. If the menu bar changes after the system has created the window, this function must be called to draw the changed menu bar.
EnableMenuItemEnables, disables, or grays the specified menu item.
EndMenuEnds the calling thread's active menu.
GetMenuRetrieves a handle to the menu assigned to the specified window.
GetMenuBarInfoRetrieves information about the specified menu bar.
GetMenuCheckMarkDimensionsRetrieves the dimensions of the default check-mark bitmap. The system displays this bitmap next to selected menu items. Before calling the SetMenuItemBitmaps function to replace the default check-mark bitmap for a menu item, an application must determine the correct bitmap size by calling GetMenuCheckMarkDimensions.
GetMenuDefaultItemDetermines the default menu item on the specified menu.
GetMenuInfoRetrieves information about a specified menu.
GetMenuItemCountRetrieves the number of items in the specified menu.
GetMenuItemIDRetrieves the menu item identifier of a menu item located at the specified position in a menu.
GetMenuItemInfoRetrieves information about a menu item.
GetMenuItemRectRetrieves the bounding rectangle for the specified menu item.
GetMenuStateRetrieves the menu flags associated with the specified menu item. If the menu item opens a submenu, this function also returns the number of items in the submenu.
GetMenuStringCopies the text string of the specified menu item into the specified buffer.
GetSubMenuRetrieves a handle to the drop-down menu or submenu activated by the specified menu item.
GetSystemMenuEnables the application to access the window menu (also known as the system menu or the control menu) for copying and modifying.
HiliteMenuItemHighlights or removes the highlighting from an item in a menu bar.
InsertMenuItemInserts a new menu item at the specified position in a menu.
IsMenuDetermines whether a handle is a menu handle.
LoadMenuLoads the specified menu resource from the executable (.exe) file associated with an application instance.
LoadMenuIndirectLoads the specified menu template in memory.
MenuItemFromPointDetermines which menu item, if any, is at the specified location.
ModifyMenuChanges an existing menu item. This function is used to specify the content, appearance, and behavior of the menu item.
RemoveMenuDeletes a menu item or detaches a submenu from the specified menu. If the menu item opens a drop-down menu or submenu, RemoveMenu does not destroy the menu or its handle, allowing the menu to be reused. Before this function is called, the GetSubMenu function should retrieve a handle to the drop-down menu or submenu.
SetMenuAssigns a new menu to the specified window.
SetMenuDefaultItemSets the default menu item for the specified menu.
SetMenuInfoSets information for a specified menu.
SetMenuItemBitmapsAssociates the specified bitmap with a menu item. Whether the menu item is selected or clear, the system displays the appropriate bitmap next to the menu item.
SetMenuItemInfoChanges information about a menu item.
TrackPopupMenuDisplays a shortcut menu at the specified location and tracks the selection of items on the menu. The shortcut menu can appear anywhere on the screen.
TrackPopupMenuExDisplays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu. The shortcut menu can appear anywhere on the screen.

The following function is obsolete.

NameDescription
InsertMenuInserts a new menu item into a menu, moving other items down the menu. Note: The InsertMenu function has been superseded by the InsertMenuItem function. You can still use InsertMenu, however, if you do not need any of the extended features of InsertMenuItem.
NameDescription
WM_COMMANDSent 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_CONTEXTMENUInforms a window that the user clicked the right mouse button (right-clicked) in the window.
WM_ENTERMENULOOPInforms an application's main window procedure that a menu modal loop has been entered.
WM_EXITMENULOOPInforms an application's main window procedure that a menu modal loop has been exited.
WM_GETTITLEBARINFOEXSent to request extended title bar information. A window receives this message through its WindowProc function.
WM_MENUCOMMANDSent when the user makes a selection from a menu.
WM_MENUDRAGSent to the owner of a drag-and-drop menu when the user drags a menu item.
WM_MENUGETOBJECTSent to the owner of a drag-and-drop menu when the mouse cursor enters a menu item or moves from the center of the item to the top or bottom of the item.
WM_MENURBUTTONUPSent when the user releases the right mouse button while the cursor is on a menu item.
WM_NEXTMENUSent to an application when the right or left arrow key is used to switch between the menu bar and the system menu.
WM_UNINITMENUPOPUPSent when a drop-down menu or submenu has been destroyed.
NameDescription
MDINEXTMENUContains information about the menu to be activated.
MENUBARINFOContains menu bar information.
MENUEX_TEMPLATE_HEADERDefines the header for an extended menu template. This structure definition is for explanation only; it is not present in any standard header file.
MENUEX_TEMPLATE_ITEMDefines a menu item in an extended menu template. This structure definition is for explanation only; it is not present in any standard header file.
MENUGETOBJECTINFOContains information about the menu that the mouse cursor is on.
MENUINFOContains information about a menu.
MENUITEMINFOContains information about a menu item.
MENUITEMTEMPLATEDefines a menu item in a menu template.
MENUITEMTEMPLATEHEADERDefines the header for a menu template. A complete menu template consists of a header and one or more menu item lists.
TPMPARAMSContains extended parameters for the TrackPopupMenuEx function.