Skip to content

Commit 1557d60

Browse files
author
Colin Robertson
authored
Merge pull request MicrosoftDocs#783 from MicrosoftDocs/master636852475618915738
Fix git push error for protected CLA branch
2 parents e52e179 + 21bb1dc commit 1557d60

14 files changed

+302
-417
lines changed

.openpublishing.redirection.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7880,6 +7880,46 @@
78807880
"redirect_url": "/cpp/windows/icons-and-cursors-image-resources-for-display-devices-image-editor-for-icons",
78817881
"redirect_document_id": false
78827882
},
7883+
{
7884+
"source_path": "docs/windows/creating-a-submenu.md",
7885+
"redirect_url": "/cpp/windows/creating-a-menu",
7886+
"redirect_document_id": false
7887+
},
7888+
{
7889+
"source_path": "docs/windows/creating-pop-up-menus.md",
7890+
"redirect_url": "/cpp/windows/creating-a-menu",
7891+
"redirect_document_id": false
7892+
},
7893+
{
7894+
"source_path": "docs/windows/creating-new-toolbars.md",
7895+
"redirect_url": "/cpp/windows/toolbar-editor",
7896+
"redirect_document_id": false
7897+
},
7898+
{
7899+
"source_path": "docs/windows/converting-bitmaps-to-toolbars.md",
7900+
"redirect_url": "/cpp/windows/toolbar-editor",
7901+
"redirect_document_id": false
7902+
},
7903+
{
7904+
"source_path": "docs/windows/creating-moving-and-editing-toolbar-buttons.md",
7905+
"redirect_url": "/cpp/windows/toolbar-editor",
7906+
"redirect_document_id": false
7907+
},
7908+
{
7909+
"source_path": "docs/windows/creating-a-tool-tip-for-a-toolbar-button.md",
7910+
"redirect_url": "/cpp/windows/toolbar-editor",
7911+
"redirect_document_id": false
7912+
},
7913+
{
7914+
"source_path": "docs/windows/how-to-add-mfc-support-to-resource-script-files.md",
7915+
"redirect_url": "/cpp/windows/how-to-create-a-resource-script-file",
7916+
"redirect_document_id": false
7917+
},
7918+
{
7919+
"source_path": "docs/windows/files-affected-by-resource-editing.md",
7920+
"redirect_url": "/cpp/windows/editable-file-types-for-resources",
7921+
"redirect_document_id": false
7922+
},
78837923
{
78847924
"source_path": "docs/windows/activationfactory-activationfactory-constructor.md",
78857925
"redirect_url": "/cpp/windows/activationfactory-class#activationfactory",

docs/windows/TOC.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212
### [Resource Files (Visual Studio)](resource-files-visual-studio.md)
1313
#### [How to: Create a Resource Script File](how-to-create-a-resource-script-file.md)
1414
#### [How to: Create a Resource](how-to-create-a-resource.md)
15-
#### [How to: Add MFC Support to Resource Script Files](how-to-add-mfc-support-to-resource-script-files.md)
1615
#### [How to: Include Resources at Compile Time](how-to-include-resources-at-compile-time.md)
1716
#### [How to: Copy Resources](how-to-copy-resources.md)
1817
#### [How to: Search for Symbols in Resources](how-to-search-for-symbols-in-resources.md)
1918
#### [How to: Use Resource Templates](how-to-use-resource-templates.md)
2019
#### [How to: Import and Export Resources](how-to-import-and-export-resources.md)
2120
#### [Editable File Types for Resources](editable-file-types-for-resources.md)
2221
#### [Editing Managed Resource Files](editing-managed-resource-files.md)
23-
#### [Files Affected by Resource Editing](files-affected-by-resource-editing.md)
2422
#### [Manifest Resources](manifest-resources.md)
2523
### [Symbols: Resource Identifiers](symbols-resource-identifiers.md)
2624
#### [Viewing Resource Symbols](viewing-resource-symbols.md)
@@ -82,18 +80,12 @@
8280
##### [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)
8381
##### [Accelerator Keys (Image Editor for Icons)](accelerator-keys-image-editor-for-icons.md)
8482
#### [Menu Editor](menu-editor.md)
85-
##### [Creating a Menu](creating-a-menu.md)
86-
##### [Creating a Submenu](creating-a-submenu.md)
87-
##### [Creating Pop-up Menus](creating-pop-up-menus.md)
83+
##### [Creating Menus](creating-a-menu.md)
8884
##### [Editing Multiple Menus or Menu Commands](selecting-multiple-menus-or-menu-commands.md)
8985
##### [Associating Menu Commands](associating-a-menu-command-with-an-accelerator-key.md)
9086
##### [Menu Command Properties](menu-command-properties.md)
9187
#### [String Editor](string-editor.md)
9288
#### [Toolbar Editor](toolbar-editor.md)
93-
##### [Creating New Toolbars](creating-new-toolbars.md)
94-
##### [Converting Bitmaps to Toolbars](converting-bitmaps-to-toolbars.md)
95-
##### [Creating, Moving, and Editing Toolbar Buttons](creating-moving-and-editing-toolbar-buttons.md)
96-
##### [Creating a Tool Tip for a Toolbar Button](creating-a-tool-tip-for-a-toolbar-button.md)
9789
#### [Version Information Editor](version-information-editor.md)
9890
# [Active Template Library (ATL)](../atl/TOC.md)
9991
# [Microsoft Foundation Classes (MFC)](../mfc/TOC.md)

docs/windows/converting-bitmaps-to-toolbars.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

docs/windows/creating-a-menu.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: "Creating a Menu (C++)"
2+
title: "Creating Menus (C++)"
33
ms.date: "11/04/2016"
44
f1_keywords: ["vc.editors.menu"]
5-
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"]
5+
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"]
66
ms.assetid: 66f94448-9b97-4b73-bf97-10d4bf87cc65
77
---
8-
# Creating a Menu (C++)
8+
# Creating Menus (C++)
99

1010
> [!NOTE]
1111
> The **Resource Window** is not available in Express editions.
@@ -33,6 +33,14 @@ For information on adding resources to managed projects, see [Resources in Deskt
3333
> [!NOTE]
3434
> To create a single-item menu on the menu bar, set the **Popup** property to **False**.
3535
36+
## To create a submenu
37+
38+
1. Select the menu command for which you want to create a submenu.
39+
40+
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.
41+
42+
1. Add additional menu commands to the submenu menu.
43+
3644
## To insert a new menu between existing menus
3745

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

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

81+
## To create pop-up menus
82+
83+
[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.
84+
85+
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.
86+
87+
### To create a pop-up menu
88+
89+
1. [Create a menu](../windows/creating-a-menu.md) with an empty title (don't provide a **Caption**).
90+
91+
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.
92+
93+
Repeat this process for any other menu commands in the pop-up menu.
94+
95+
1. Save the menu resource.
96+
97+
### To connect a pop-up menu to your application
98+
99+
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).
100+
101+
1. Add the following code to the message handler:
102+
103+
```cpp
104+
CMenu menu;
105+
VERIFY(menu.LoadMenu(IDR_MENU1));
106+
CMenu* pPopup = menu.GetSubMenu(0);
107+
ASSERT(pPopup != NULL);
108+
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd());
109+
```
110+
111+
> [!NOTE]
112+
> The [CPoint](../atl-mfc-shared/reference/cpoint-class.md) passed by the message handler is in screen coordinates.
113+
114+
> [!NOTE]
115+
> Connecting a pop-up menu to your application requires MFC.
116+
117+
### To view a menu resource as a pop-up menu
118+
119+
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.
120+
121+
Right-click the menu and choose **View as Popup** from the shortcut menu.
122+
123+
This option is only a viewing preference and won't modify your menu.
124+
125+
> [!NOTE]
126+
> To change back to the menu-bar view, click **View as Popup** again (which removes the check mark and returns your menu-bar view).
127+
73128
## Requirements
74129

75130
Win32
76131

77-
## See Also
132+
## See also
78133

79134
[Menu Editor](../windows/menu-editor.md)

docs/windows/creating-a-submenu.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/windows/creating-a-tool-tip-for-a-toolbar-button.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)