Compartilhar via


TrackPopupMenu (Windows CE 5.0)

Send Feedback

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.

BOOLTrackPopupMenu(HMENUhMenu, UINTuFlags, intx, inty, intnReserved, HWNDhWnd, constRECT* prcRect );

Parameters

  • hMenu
    [in] Handle to the shortcut menu to be displayed. The handle can be obtained by calling CreatePopupMenu to create a new shortcut menu, or by calling GetSubMenu to retrieve the handle to a submenu associated with an existing menu item.

  • uFlags
    [in] Bit flags specifying how TrackPopupMenu positions the shortcut menu. The following table shows the possible values for horizontal positioning.

    Value Description
    TPM_CENTERALIGN Centers the shortcut menu horizontally relative to the coordinate specified by the x parameter.
    TPM_LEFTALIGN Positions the shortcut menu so that its left side is aligned with the coordinate specified by the x parameter.
    TPM_RIGHTALIGN Positions the shortcut menu so that its right side is aligned with the coordinate specified by the x parameter.

    The following table shows the possible flag values for vertical positioning.

    Value Description
    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 y parameter.
    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 y parameter.
    TPM_VCENTERALIGN If this flag is set, the function centers the shortcut menu vertically relative to the coordinate specified by the y parameter.

    Use the values shown in the following table 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] The horizontal location of the shortcut menu, in screen coordinates.

  • y
    [in] 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_COMMAND message from the menu until the function returns.

  • prcRect
    [in] Ignored.

Return Values

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, then 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.

If hWnd is mirrored, the shortcut menu that it owns will be created as mirrored, otherwise it will be a left-to-right (not-mirrored) shortcut menu.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winuser.h.
Link Library: Menu.lib.

See Also

CreatePopupMenu | GetSubMenu | RECT | WM_COMMAND | Menus Functions

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.