Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .openpublishing.redirection.json
Original file line number Diff line number Diff line change
Expand Up @@ -7880,6 +7880,46 @@
"redirect_url": "/cpp/windows/icons-and-cursors-image-resources-for-display-devices-image-editor-for-icons",
"redirect_document_id": false
},
{
"source_path": "docs/windows/creating-a-submenu.md",
"redirect_url": "/cpp/windows/creating-a-menu",
"redirect_document_id": false
},
{
"source_path": "docs/windows/creating-pop-up-menus.md",
"redirect_url": "/cpp/windows/creating-a-menu",
"redirect_document_id": false
},
{
"source_path": "docs/windows/creating-new-toolbars.md",
"redirect_url": "/cpp/windows/toolbar-editor",
"redirect_document_id": false
},
{
"source_path": "docs/windows/converting-bitmaps-to-toolbars.md",
"redirect_url": "/cpp/windows/toolbar-editor",
"redirect_document_id": false
},
{
"source_path": "docs/windows/creating-moving-and-editing-toolbar-buttons.md",
"redirect_url": "/cpp/windows/toolbar-editor",
"redirect_document_id": false
},
{
"source_path": "docs/windows/creating-a-tool-tip-for-a-toolbar-button.md",
"redirect_url": "/cpp/windows/toolbar-editor",
"redirect_document_id": false
},
{
"source_path": "docs/windows/how-to-add-mfc-support-to-resource-script-files.md",
"redirect_url": "/cpp/windows/how-to-create-a-resource-script-file",
"redirect_document_id": false
},
{
"source_path": "docs/windows/files-affected-by-resource-editing.md",
"redirect_url": "/cpp/windows/editable-file-types-for-resources",
"redirect_document_id": false
},
{
"source_path": "docs/windows/activationfactory-activationfactory-constructor.md",
"redirect_url": "/cpp/windows/activationfactory-class#activationfactory",
Expand Down
10 changes: 1 addition & 9 deletions docs/windows/TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
### [Resource Files (Visual Studio)](resource-files-visual-studio.md)
#### [How to: Create a Resource Script File](how-to-create-a-resource-script-file.md)
#### [How to: Create a Resource](how-to-create-a-resource.md)
#### [How to: Add MFC Support to Resource Script Files](how-to-add-mfc-support-to-resource-script-files.md)
#### [How to: Include Resources at Compile Time](how-to-include-resources-at-compile-time.md)
#### [How to: Copy Resources](how-to-copy-resources.md)
#### [How to: Search for Symbols in Resources](how-to-search-for-symbols-in-resources.md)
#### [How to: Use Resource Templates](how-to-use-resource-templates.md)
#### [How to: Import and Export Resources](how-to-import-and-export-resources.md)
#### [Editable File Types for Resources](editable-file-types-for-resources.md)
#### [Editing Managed Resource Files](editing-managed-resource-files.md)
#### [Files Affected by Resource Editing](files-affected-by-resource-editing.md)
#### [Manifest Resources](manifest-resources.md)
### [Symbols: Resource Identifiers](symbols-resource-identifiers.md)
#### [Viewing Resource Symbols](viewing-resource-symbols.md)
Expand Down Expand Up @@ -82,18 +80,12 @@
##### [Icons and Cursors: Image Resources for Display Devices (Image Editor for Icons)](icons-and-cursors-image-resources-for-display-devices-image-editor-for-icons.md)
##### [Accelerator Keys (Image Editor for Icons)](accelerator-keys-image-editor-for-icons.md)
#### [Menu Editor](menu-editor.md)
##### [Creating a Menu](creating-a-menu.md)
##### [Creating a Submenu](creating-a-submenu.md)
##### [Creating Pop-up Menus](creating-pop-up-menus.md)
##### [Creating Menus](creating-a-menu.md)
##### [Editing Multiple Menus or Menu Commands](selecting-multiple-menus-or-menu-commands.md)
##### [Associating Menu Commands](associating-a-menu-command-with-an-accelerator-key.md)
##### [Menu Command Properties](menu-command-properties.md)
#### [String Editor](string-editor.md)
#### [Toolbar Editor](toolbar-editor.md)
##### [Creating New Toolbars](creating-new-toolbars.md)
##### [Converting Bitmaps to Toolbars](converting-bitmaps-to-toolbars.md)
##### [Creating, Moving, and Editing Toolbar Buttons](creating-moving-and-editing-toolbar-buttons.md)
##### [Creating a Tool Tip for a Toolbar Button](creating-a-tool-tip-for-a-toolbar-button.md)
#### [Version Information Editor](version-information-editor.md)
# [Active Template Library (ATL)](../atl/TOC.md)
# [Microsoft Foundation Classes (MFC)](../mfc/TOC.md)
Expand Down
48 changes: 0 additions & 48 deletions docs/windows/converting-bitmaps-to-toolbars.md

This file was deleted.

63 changes: 59 additions & 4 deletions docs/windows/creating-a-menu.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: "Creating a Menu (C++)"
title: "Creating Menus (C++)"
ms.date: "11/04/2016"
f1_keywords: ["vc.editors.menu"]
helpviewer_keywords: ["mnemonics [C++], associating menu items", "menus [C++], associating commands with mnemonic keys", "menus [C++], creating", "menus [C++], adding items", "commands [C++], adding to menus", "menu items, adding to menus"]
helpviewer_keywords: ["mnemonics [C++], associating menu items", "menus [C++], associating commands with mnemonic keys", "menus [C++], creating", "menus [C++], adding items", "commands [C++], adding to menus", "menu items, adding to menus", "submenus", "submenus [C++], creating", "menus [C++], creating", "context menus [C++], Menu Editor", "pop-up menus [C++], creating", "menus [C++], pop-up", "menus [C++], creating", "shortcut menus [C++], creating", "pop-up menus [C++], displaying", "pop-up menus [C++], connecting to applications", "context menus [C++], connecting to applications", "shortcut menus [C++], connecting to applications", "pop-up menus"]
ms.assetid: 66f94448-9b97-4b73-bf97-10d4bf87cc65
---
# Creating a Menu (C++)
# Creating Menus (C++)

> [!NOTE]
> The **Resource Window** is not available in Express editions.
Expand Down Expand Up @@ -33,6 +33,14 @@ For information on adding resources to managed projects, see [Resources in Deskt
> [!NOTE]
> To create a single-item menu on the menu bar, set the **Popup** property to **False**.

## To create a submenu

1. Select the menu command for which you want to create a submenu.

1. In the **New Item** box that appears to the right, type the name of the new menu command. This new command will appear first on the submenu menu.

1. Add additional menu commands to the submenu menu.

## To insert a new menu between existing menus

Select an existing menu name and press the **Insert** key. The **New Item** box is inserted before the selected item.
Expand Down Expand Up @@ -70,10 +78,57 @@ Right-click on the menu bar and choose **Insert New** from the shortcut menu.

The new item box is selected so you can create additional menu commands.

## To create pop-up menus

[Pop-up menus](../mfc/menus-mfc.md) display frequently used commands. They can be context sensitive to the location of the pointer. Using pop-up menus in your application requires building the menu itself and then connecting it to application code.

Once you've created the menu resource, your application code needs to load the menu resource and use [TrackPopupMenu](/windows/desktop/api/winuser/nf-winuser-trackpopupmenu) to cause the menu to appear. Once the user has dismissed the pop-up menu by selecting outside it, or has selected a command, that function will return. If the user chooses a command, that command message will be sent to the window whose handle was passed.

### To create a pop-up menu

1. [Create a menu](../windows/creating-a-menu.md) with an empty title (don't provide a **Caption**).

1. [Add a menu command to the new menu](../windows/adding-commands-to-a-menu.md). Move to the first menu command below the blank menu title (the temporary caption says `Type Here`). Type a **Caption** and any other information.

Repeat this process for any other menu commands in the pop-up menu.

1. Save the menu resource.

### To connect a pop-up menu to your application

1. Add a message handler for WM_CONTEXTMENU (for example). For more information, see [Mapping Messages to Functions](../mfc/reference/mapping-messages-to-functions.md).

1. Add the following code to the message handler:

```cpp
CMenu menu;
VERIFY(menu.LoadMenu(IDR_MENU1));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd());
```

> [!NOTE]
> The [CPoint](../atl-mfc-shared/reference/cpoint-class.md) passed by the message handler is in screen coordinates.

> [!NOTE]
> Connecting a pop-up menu to your application requires MFC.

### To view a menu resource as a pop-up menu

Normally, when you're working in the **Menu** editor, a menu resource is displayed as a menu bar. However, you might have menu resources that are added to the application's menu bar while the program is running.

Right-click the menu and choose **View as Popup** from the shortcut menu.

This option is only a viewing preference and won't modify your menu.

> [!NOTE]
> To change back to the menu-bar view, click **View as Popup** again (which removes the check mark and returns your menu-bar view).

## Requirements

Win32

## See Also
## See also

[Menu Editor](../windows/menu-editor.md)
25 changes: 0 additions & 25 deletions docs/windows/creating-a-submenu.md

This file was deleted.

41 changes: 0 additions & 41 deletions docs/windows/creating-a-tool-tip-for-a-toolbar-button.md

This file was deleted.

Loading