Microsoft Windows CE 3.0  

TrackPopupMenu

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This function displays a floating pop-up menu at the specified location and tracks the selection of items on the pop-up menu. The floating pop-up menu can appear anywhere on the screen.

BOOL
TrackPopupMenu(
HMENU
hMenu
,
UINT
uFlags
,
int
x
,
int
y
,
int
nReserved
,
HWND
hWnd
,
const
RECT
*
prcRect
);

Parameters

hMenu
[in] Handle to the shortcut menu to be displayed. The handle can be obtained by calling CreatePopupMenuto create a new shortcut menu, or by calling GetSubMenuto retrieve the handle to a submenu associated with an existing menu item.
uFlags
[in] A set of bit flags that specify function options.

Use one of the following bit flag constants to specify how the function positions the shortcut menu horizontally.

Value Description
TPM_CENTERALIGN If this flag is set, the function centers the shortcut menu horizontally relative to the coordinate specified by the xparameter.
TPM_LEFTALIGN If this flag is set, the function positions the shortcut menu so that its left side is aligned with the coordinate specified by the xparameter.
TPM_RIGHTALIGN Positions the shortcut menu so that its right side is aligned with the coordinate specified by the xparameter.

Use one of the following bit flag constants to specify how the function positions the shortcut menu vertically.

TPM_BOTTOMALIGN If this flag is set, the function positions the shortcut menu so that its bottom side is aligned with the coordinate specified by the yparameter.
TPM_TOPALIGN If this flag is set, the function positions the shortcut menu so that its top side is aligned with the coordinate specified by the yparameter.
TPM_VCENTERALIGN If this flag is set, the function centers the shortcut menu vertically relative to the coordinate specified by the yparameter.

Use the following bit flag constants to determine the user selection without having to set up a parent window for the menu.

Value Description
TPM_NONOTIFY Unsupported.
TPM_RETURNCMD If this flag is set, the function returns the menu item identifier of the user's selection in the return value.
x
[in] Specifies the horizontal location of the shortcut menu, in screen coordinates.
y
[in] Specifies the vertical location of the shortcut menu, in screen coordinates.
nReserved
[in] Reserved; set to zero.
hWnd
[in] Handle to the window that owns the shortcut menu. This window receives all messages from the menu. The window does not receive a WM_COMMANDmessage from the menu until the function returns.

If you specify TPM_NONOTIFY in the uFlagsparameter, 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.

prcRect
[in] Ignored.

Return Values

If you specify TPM_RETURNCMD in the uFlagsparameter, 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, then the return value is zero.

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

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winuser.h   Menu.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CreatePopupMenu, GetLastError, GetSubMenu, RECT, WM_COMMAND