TrackPopupMenu

Version 3.0

Syntax

BOOL TrackPopupMenu(hMenu,wFlags,x,y,nReserved,hWnd,lpReserved)

This function displays a “floating” pop-up menu at the specified location and tracks the selection of items on the pop-up menu. A floating pop-up menu can appear anywhere on the screen. The hMenu parameter specifies the handle of the menu to be displayed; the application obtains this handle by calling CreatePopupMenu to create a new pop-up menu or by calling GetSubMenu to retrieve the handle of a pop-up menu associated with an existing menu item.

Windows sends messages generated by the menu to the window identified by the hWnd parameter.

Parameter Type/Description  

hMenu HMENU Identifies the pop-up menu to be displayed.  
wFlags WORD Specifies the mouse button that selects items on the menu. If wFlags is set to TPM_RIGHTBUTTON, the right mouse button selects items on the menu. Otherwise, the left button selects items on the menu.  
x int Specifies the horizontal position in screen coordinates of the left side of the menu on the screen.  
y int Specifies the vertical position in screen coordinates of the top of the menu on the screen.  
nReserved int Is reserved and must be set to zero.  
hWnd HWND Identifies the window which owns the pop-up menu. This window receives all WM_COMMAND messages from the menu.  
lpReserved LPVOID Is reserved and must be set to NULL.  

Return Value

The return value specifies the outcome of the function. It is TRUE if the function is successful. Otherwise, it is FALSE.