Поделиться через


Connecting a Pop-up Menu to Your Application

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.

  2. 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: Localizing Windows Forms and Walkthrough: Using Resources for Localization with ASP.NET.

Requirements

MFC

See Also

Tasks

Creating Pop-up Menus

Reference

Menu Editor

Menus