Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
CalculatePopupWindowPosition function (winuser.h)
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 CalculatePopupWindowPosition(
[in] const POINT *anchorPoint,
[in] const SIZE *windowSize,
[in] UINT flags,
[in, optional] RECT *excludeRect,
[out] RECT *popupWindowPosition
);
Parameters
[in] anchorPoint
Type: const POINT*
The specified anchor point.
[in] windowSize
Type: const SIZE*
The specified window size.
[in] flags
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.
| Value | Meaning |
|---|---|
|
Centers pop-up window horizontally relative to the coordinate specified by the anchorPoint->x parameter. |
|
Positions the pop-up window so that its left edge is aligned with the coordinate specified by the anchorPoint->x parameter. |
|
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.
| Value | Meaning |
|---|---|
|
Positions the pop-up window so that its bottom edge is aligned with the coordinate specified by the anchorPoint->y parameter. |
|
Positions the pop-up window so that its top edge is aligned with the coordinate specified by the anchorPoint->y parameter. |
|
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.
| Value | Meaning |
|---|---|
|
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. |
|
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.
| Value | Meaning |
|---|---|
|
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. |
[in, optional] excludeRect
Type: RECT*
A pointer to a structure that specifies the exclude rectangle. It can be NULL.
[out] popupWindowPosition
Type: RECT*
A pointer to a structure that specifies the pop-up window position.
Return value
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
| Requirement | Value |
|---|---|
| Minimum supported client | Windows 7 [desktop apps only] |
| Minimum supported server | Windows Server 2008 R2 [desktop apps only] |
| Target Platform | Windows |
| Header | winuser.h (include Windows.h) |
| Library | User32.lib |
| DLL | User32.dll |
See also
Reference
Feedback
Was this page helpful?
