다음을 통해 공유


Creating Pop-up Menus

Pop-up menus 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.

Once you have created the menu resource, your application code needs to load the menu resource and use 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.

To create a pop-up menu

  1. Create a menu with an empty title (don't provide a Caption).

  2. Add a menu command to the new menu. Move to the first menu command below the blank menu title (the temporary caption says Type Here). Type a Caption and any other information.

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

  3. Save the menu resource.

    Tip

    For more information on viewing the pop-up menu, see Viewing a Menu as a Pop-Up Menu.

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

Win32

See Also

Tasks

Connecting a Pop-up Menu to Your Application

Reference

Menu Editor

Menus