Help Center

AddPopupfunction

Adds a popup child menu to an existing menu.

Windowsfunctiondoc-orphan
No implementation located. This member is documented, but the source scan found no matching declaration. It is likely declared in a header this scan does not resolve, or provided by a macro.

Syntax

FUNCTION AddPopup (BYVAL hMenu AS HMENU, BYVAL hPopup AS HMENU, BYVAL fState AS UINT, BYVAL item AS LONG, BYREF wszText AS WSTRING, BYVAL fByPosition AS BOOLEAN = FALSE) AS BOOLEAN

Parameters

NameDescription
hMenuHandle of the parent menu which holds the popup.
hPopupHandle of the child popup menu to be added.
fStateThe initial state of the menu item. It can be one of the following:
MFS_DISABLED: Disable the item so that it cannot be selected.
MFS_ENABLED: Enable the item so that it can be selected.
itemIf the option is included, item is a unique numeric identifier for this popup menu. item may be used later with a fByPosition option to reference this popup. item is an integral numeric value in the range of -32768 to +32767.
wszTextText displayed in the parent menu. An ampersand (&) may be used in the to make the following letter into a control accelerator (hot-key). The letter appears underscored to signify that it is an accelerator.
fByPositionIndicates the position in the parent menu where the popup child menu is to be inserted. If the fByPosition option is used, the popup menu is inserted prior to the menu item specified by item. Otherwise, the popup menu is inserted at the physical position within the parent menu, where position = 1 for the first position, position = 2 for the second, and so on. If position is not specified then the popup menu is appended to the end of the menu.

Return value

Returns TRUE if the function succeeds; FALSE otherwise.

Description

Adds a popup child menu to an existing menu. A popup menu is a small window that "pops up" when a menu item is highlighted. This allows nesting, and gives the user an opportunity to choose from "sub-menu" items.

Example

DIM hSubPopUpMenu AS HMENU = CMenu.CreatePopUp

CMenu.AddPopup hPopUpMenu, hSubPopUpMenu, MF_ENABLED, 4001, "Nested submenu 1"
CMenu.Append hSubPopUpMenu, MF_ENABLED, 4002, "Nested submenu 1 item 1"
CMenu.Append hSubPopUpMenu, MF_ENABLED, 4003, "Nested submenu 1 item 2"
CMenu.Append hSubPopUpMenu, MF_SEPARATOR, 0, ""

DIM hSubPopUpMenu2 AS HMENU = CMenu.CreatePopUp

CMenu.AddPopup hSubPopUpMenu, hSubPopUpMenu2, MF_ENABLED, 5001, "Nested submenu 2"
CMenu.Append hSubPopUpMenu2, MF_ENABLED, 5002, "Nested submenu 2 item 1"
CMenu.Append hSubPopUpMenu2, MF_ENABLED, 5003, "Nested submenu 2 item 2"

Reference

  • Documented in Windows/WIndows Controls/CMenu Class.md
  • Topic: About Menus