CMenu::TrackPopupMenu

Syntax

BOOL TrackPopupMenu( UINT nFlags, int x, int y, const CWnd* pWnd, LPRECT lpRectReserved = 0);

Parameters

nFlags

Specifies a screen-position flag and a mouse-button flag. The screen-position flag can be one of the following:

Value Meaning

TPM_CENTERALIGN Centers the pop-up menu horizontally relative to the coordinate specified by x.
TPM_LEFTALIGN Positions the pop-up menu so that its left side is aligned with the coordinate specified by x.
TPM_RIGHTALIGN Positions the pop-up menu so that its right side is aligned with the coordinate specified by x.

The mouse-button flag can be one of the following:

Value Meaning

TPM_LEFTBUTTON Causes the pop-up menu to track the left mouse button.
TPM_RIGHTBUTTON Causes the pop-up menu to track the right mouse button.

x

Specifies the horizontal position in screen coordinates of the left side of the menu on the screen.

y

Specifies the vertical position in screen coordinates of the top of the menu on the screen.

pWnd

Identifies the window that owns the pop-up menu. This window receives all WM_COMMAND messages from the menu.

lpRectReserved

Points to a RECT structure or CPoint object that contains the screen coordinates of a rectangle within which the user can click without dismissing the pop-up menu. If this parameter is NULL, the pop-up menu is dismissed if the user clicks outside the pop-up menu. This must be NULL for Windows version 3.0.

Remarks

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.

Return Value

TRUE if the function is successful; otherwise FALSE.

See Also

CMenu::CreatePopupMenu, CMenu::GetSubMenu, ::TrackPopupMenu