Skip to content

Commit 65c56e9

Browse files
authored
Merge pull request #1704 from msebolt/resource-file-consolidation-pr20
resource file consolidation pr20
2 parents c7451b0 + 6bd6ce9 commit 65c56e9

5 files changed

Lines changed: 46 additions & 71 deletions

‎.openpublishing.redirection.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7525,6 +7525,16 @@
75257525
"redirect_url": "/cpp/windows/creating-a-menu",
75267526
"redirect_document_id": false
75277527
},
7528+
{
7529+
"source_path": "docs/windows/connecting-a-pop-up-menu-to-your-application.md",
7530+
"redirect_url": "/cpp/windows/creating-pop-up-menus",
7531+
"redirect_document_id": false
7532+
},
7533+
{
7534+
"source_path": "docs/windows/viewing-a-menu-as-a-pop-up-menu.md",
7535+
"redirect_url": "/cpp/windows/creating-pop-up-menus",
7536+
"redirect_document_id": false
7537+
},
75287538
{
75297539
"source_path": "docs/windows/activationfactory-activationfactory-constructor.md",
75307540
"redirect_url": "/cpp/windows/activationfactory-class#activationfactory",

‎docs/windows/TOC.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@
132132
##### [Deleting Menus and Menu Commands](deleting-menus-and-menu-commands.md)
133133
##### [Creating a Submenu](creating-a-submenu.md)
134134
##### [Creating Pop-up Menus](creating-pop-up-menus.md)
135-
###### [Connecting a Pop-up Menu to Your Application](connecting-a-pop-up-menu-to-your-application.md)
136-
###### [Viewing a Menu as a Pop-up Menu](viewing-a-menu-as-a-pop-up-menu.md)
137135
##### [Selecting Multiple Menus or Menu Commands](selecting-multiple-menus-or-menu-commands.md)
138136
##### [Moving and Copying Menus and Menu Commands](moving-and-copying-menus-and-menu-commands.md)
139137
##### [Associating a Menu Command with an Accelerator Key](associating-a-menu-command-with-an-accelerator-key.md)

‎docs/windows/connecting-a-pop-up-menu-to-your-application.md‎

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,60 @@
11
---
22
title: "Creating Pop-up Menus (C++)"
33
ms.date: "11/04/2016"
4-
helpviewer_keywords: ["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"]
4+
helpviewer_keywords: ["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"]
55
ms.assetid: dff4dddf-2e8d-4c34-b755-90baae426b58
66
---
77
# Creating Pop-up Menus (C++)
88

99
[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.
1010

11-
Once you have 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 clicking outside it, or has clicked on 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.
11+
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.
1212

13-
### To create a pop-up menu
13+
## To create a pop-up menu
1414

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

17-
2. [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.
17+
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.
1818

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

21-
3. Save the menu resource.
21+
1. Save the menu resource.
2222

23-
> [!TIP]
24-
> For more information on viewing the pop-up menu, see [Viewing a Menu as a Pop-Up Menu](../windows/viewing-a-menu-as-a-pop-up-menu.md).
23+
## To connect a pop-up menu to your application
24+
25+
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).
26+
27+
1. Add the following code to the message handler:
28+
29+
```cpp
30+
CMenu menu;
31+
VERIFY(menu.LoadMenu(IDR_MENU1));
32+
CMenu* pPopup = menu.GetSubMenu(0);
33+
ASSERT(pPopup != NULL);
34+
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd());
35+
```
36+
37+
> [!NOTE]
38+
> The [CPoint](../atl-mfc-shared/reference/cpoint-class.md) passed by the message handler is in screen coordinates.
39+
40+
> [!NOTE]
41+
> Connecting a pop-up menu to your application requires MFC.
42+
43+
## To view a menu resource as a pop-up menu
44+
45+
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.
46+
47+
Right-click the menu and choose **View as Popup** from the shortcut menu.
48+
49+
This option is only a viewing preference and won't modify your menu.
50+
51+
> [!NOTE]
52+
> To change back to the menu-bar view, click **View as Popup** again (which removes the check mark and returns your menu-bar view).
2553
2654
## Requirements
2755

2856
Win32
2957

3058
## See Also
3159

32-
[Connecting a Pop-up Menu to Your Application](../windows/connecting-a-pop-up-menu-to-your-application.md)<br/>
33-
[Menu Editor](../windows/menu-editor.md)
60+
[Menu Editor](../windows/menu-editor.md)

‎docs/windows/viewing-a-menu-as-a-pop-up-menu.md‎

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

0 commit comments

Comments
 (0)