User32TrackPopupMenu Method

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

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", SetLastError = true)]
public static int TrackPopupMenu(
	IntPtr hMenu,
	TrackPopupMenuFlags flags,
	int x,
	int y,
	int reserved,
	IntPtr hWnd,
	[OptionalAttribute] IntPtr prcRect
)

Parameters

hMenu  IntPtr
A handle to the menu to be displayed.

The handle can be obtained by calling CreatePopupMenu to create a new menu, or by calling GetSubMenu to retrieve a handle to a submenu associated with an existing menu item.

flags  TrackPopupMenuFlags
Flags that specifies the alignment, discovery and animations of the menu.
x  Int32
The horizontal location of the menu, in screen coordinates.
y  Int32
The vertical location of the menu, in screen coordinates.
reserved  Int32
Reserved; must be zero.
hWnd  IntPtr
A handle to the window that owns the 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 NoSendNotify in the flags parameter, the function does not send messages to the window identified by hWnd parameter. However, you must still pass a window handle in hWnd parameter.

It can be any window handle from your application.

prcRect  IntPtr  (Optional)
Ignored; must be Zero.

Return Value

Int32
If you specify ReturnCmd in the flags 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 ReturnCmd in the flags parameter, the return value is nonzero if the function succeeds and zero if it fails.

To get extended error information, call GetLastWin32Error.

Remarks

See Also