CreatePopupMenu

3.0

  HMENU CreatePopupMenu(void)    

The CreatePopupMenu function creates an empty pop-up menu.

Parameters

This function has no parameters.

Return Value

The return value is the handle of the newly created menu if the function is successful. Otherwise, it is NULL.

Comments

An application adds items to the pop-up menu by calling the InsertMenu and AppendMenu functions. The application can add the pop-up menu to an existing menu or pop-up menu, or it can display and track selections on the pop-up menu by calling the TrackPopupMenu function.

Before exiting, an application must free system resources associated with a pop-up menu if the menu is not assigned to a window. An application frees a menu by calling the DestroyMenu function.

Example

The following example creates a main menu and a pop-up menu, and associates the pop-up menu with an item in the main menu:

HMENU hmenu;
HMENU hmenuPopup;

/* Create the main and pop-up menu handles. */

hmenu = CreateMenu();
hmenuPopup = CreatePopupMenu();

/* Create the pop-up menu items. *./

AppendMenu(hmenuPopup, MF_ENABLED | MF_STRING, IDM_NEW,
    "&New");
AppendMenu(hmenuPopup, MF_ENABLED | MF_STRING, IDM_SAVE,
    "&Save");
AppendMenu(hmenuPopup, MF_ENABLED | MF_STRING, IDM_SAVE_AS,
    "&Save As");

/* Add the pop-up menu to the main menu. */

AppendMenu(hmenu, MF_ENABLED | MF_POPUP, (UINT) hmenuPopup,
    "&File");

See Also

AppendMenu, CreateMenu, InsertMenu, SetMenu, TrackPopupMenu