Help Center

TrackPopupMenuExfunction

Displays a shortcut menu at the specified location and tracks the selection of items on the 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 TrackPopupMenuEx (BYVAL hMenu AS HMENU, BYVAL uFlags AS UINT, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL hwnd AS HWND, BYVAL ptpm AS TPMPARAMS PTR = NULL) AS BOOLEAN

Parameters

NameDescription
hMenuA handle to the shortcut menu to be displayed. The handle can be obtained by calling CMenu.CreatePopup to create a new shortcut menu, or by calling CMenu.GetSubMenu to retrieve a handle to a submenu associated with an existing menu item.
uFlagsUse zero of more of these flags to specify function options (see below).
xThe horizontal location of the shortcut menu, in screen coordinates.
yThe vertical location of the shortcut menu, in screen coordinates.
hWndA handle to the window that owns the shortcut menu. This window receives all messages from the menu. The window does not receive a WM_COMMAND message from the menu until the function returns. If you specify TPM_NONOTIFY in the uFlags parameter, the function does not send messages to the window identified by hWnd. However, you must still pass a window handle in hWnd. It can be any window handle from your application.
ptpmA pointer to a TPMPARAMS structure that specifies an area of the screen the menu should not overlap. This parameter can be NULL.

Return value

If you specify TPM_RETURNCMD in the uFlags parameter, the return value is the menu-item identifier of the item that the user selected. If the user cancels the menu without making a selection, or if an error occurs, the return value is zero.

If you do not specify TPM_RETURNCMD in the uFlags parameter, the return value is nonzero if the function succeeds and zero if it fails. To get extended error information, call GetLastError.

Description

Displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu. The shortcut menu can appear anywhere on the screen.

Use one of the following flags to specify how the function positions the shortcut menu horizontally.

Use one of the following flags to specify how the function positions the shortcut menu vertically.

Use the following flags to control discovery of the user selection without having to set up a parent window for the menu.

Use one of the following flags to specify which mouse button the shortcut menu tracks.

Use any reasonable combination of the following flags to modify the animation of a menu. For example, by selecting a horizontal and a vertical flag, you can achieve diagonal animation.

For any animation to occur, the SystemParametersInfo function must set SPI_SETMENUANIMATION. Also, all the TPM_*ANIMATION flags, except TPM_NOANIMATION, are ignored if menu fade animation is on. For more information, see the SPI_GETMENUFADE flag in SystemParametersInfo.

Use the TPM_RECURSE flag to display a menu when another menu is already displayed. This is intended to support context menus within a menu.

For right-to-left text layout, use TPM_LAYOUTRTL. By default, the text layout is left-to-right.

Reference

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