Export (0) Print
Expand All
Expand Minimize

CalculatePopupWindowPosition function

Calculates an appropriate pop-up window position using the specified anchor point, pop-up window size, flags, and the optional exclude rectangle. When the specified pop-up window size is smaller than the desktop window size, use the CalculatePopupWindowPosition function to ensure that the pop-up window is fully visible on the desktop window, regardless of the specified anchor point.

Syntax


BOOL WINAPI CalculatePopupWindowPosition(
  _In_      const POINT *anchorPoint,
  _In_      const SIZE *windowSize,
  _In_      UINT flags,
  _In_opt_  RECT *excludeRect,
  _Out_     RECT *popupWindowPosition
);

Parameters

anchorPoint [in]

Type: const POINT*

The specified anchor point.

windowSize [in]

Type: const SIZE*

The specified window size.

flags [in]

Type: UINT

Use one of the following flags to specify how the function positions the pop-up window horizontally and vertically. The flags are the same as the vertical and horizontal positioning flags of the TrackPopupMenuEx function.

Use one of the following flags to specify how the function positions the pop-up window horizontally.

ValueMeaning
TPM_CENTERALIGN
0x0004L

Centers pop-up window horizontally relative to the coordinate specified by the anchorPoint->x parameter.

TPM_LEFTALIGN
0x0000L

Positions the pop-up window so that its left edge is aligned with the coordinate specified by the anchorPoint->x parameter.

TPM_RIGHTALIGN
0x0008L

Positions the pop-up window so that its right edge is aligned with the coordinate specified by the anchorPoint->x parameter.

 

Uses one of the following flags to specify how the function positions the pop-up window vertically.

ValueMeaning
TPM_BOTTOMALIGN
0x0020L

Positions the pop-up window so that its bottom edge is aligned with the coordinate specified by the anchorPoint->y parameter.

TPM_TOPALIGN
0x0000L

Positions the pop-up window so that its top edge is aligned with the coordinate specified by the anchorPoint->y parameter.

TPM_VCENTERALIGN
0x0010L

Centers the pop-up window vertically relative to the coordinate specified by the anchorPoint->y parameter.

 

Use one of the following flags to specify whether to accommodate horizontal or vertical alignment.

ValueMeaning
TPM_HORIZONTAL
0x0000L

If the pop-up window cannot be shown at the specified location without overlapping the excluded rectangle, the system tries to accommodate the requested horizontal alignment before the requested vertical alignment.

TPM_VERTICAL
0x0040L

If the pop-up window cannot be shown at the specified location without overlapping the excluded rectangle, the system tries to accommodate the requested vertical alignment before the requested horizontal alignment.

 

The following flag is available starting with Windows 7.

ValueMeaning
TPM_WORKAREA
0x10000L

Restricts the pop-up window to within the work area. If this flag is not set, the pop-up window is restricted to the work area only if the input point is within the work area. For more information, see the rcWork and rcMonitor members of the MONITORINFO structure.

 

excludeRect [in, optional]

Type: RECT*

A pointer to a structure that specifies the exclude rectangle. It can be NULL.

popupWindowPosition [out]

Type: RECT*

A pointer to a structure that specifies the pop-up window position.

Return value

Type:

Type: BOOL

If the function succeeds, it returns TRUE; otherwise, it returns FALSE. To get extended error information, call GetLastError.

Remarks

TPM_WORKAREA is supported for the TrackPopupMenu and TrackPopupMenuEx functions.

Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
TrackPopupMenu
TrackPopupMenuEx

 

 

Community Additions

ADD
Show:
© 2014 Microsoft