Connecting a Pop-up Menu to Your Application
For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.
For the latest documentation on Visual Studio 2017, see Connecting a Pop-up Menu to Your Application on docs.microsoft.com.
To connect a pop-up menu to your application
Add a message handler for
WM_CONTEXTMENU
(for example). For more information, see Mapping Messages to Functions.Add the following code to the message handler:
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 passed by the message handler is in screen coordinates.
For information on adding resources to managed projects, please see Resources in Applications in the .NET Framework Developer's Guide. For information on manually adding resource files to managed projects, accessing resources, displaying static resources, and assigning resources strings to properties, see Walkthrough: Using Resources for Localization with ASP.NET.
Requirements
MFC