Skip to content

Commit eedb5ee

Browse files
authored
Merge pull request MicrosoftDocs#1741 from msebolt/resource-file-consolidation-pr42
resource file consolidation pr42
2 parents 759f7b2 + c39538e commit eedb5ee

File tree

5 files changed

+70
-92
lines changed

5 files changed

+70
-92
lines changed

.openpublishing.redirection.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7880,6 +7880,16 @@
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+
},
78837893
{
78847894
"source_path": "docs/windows/activationfactory-activationfactory-constructor.md",
78857895
"redirect_url": "/cpp/windows/activationfactory-class#activationfactory",

docs/windows/TOC.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@
8282
##### [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)
8383
##### [Accelerator Keys (Image Editor for Icons)](accelerator-keys-image-editor-for-icons.md)
8484
#### [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)
85+
##### [Creating Menus](creating-a-menu.md)
8886
##### [Editing Multiple Menus or Menu Commands](selecting-multiple-menus-or-menu-commands.md)
8987
##### [Associating Menu Commands](associating-a-menu-command-with-an-accelerator-key.md)
9088
##### [Menu Command Properties](menu-command-properties.md)

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-pop-up-menus.md

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

0 commit comments

Comments
 (0)