DeferWindowPos

3.0

  HDWP DeferWindowPos(hdwp, hwnd, hwndInsertAfter, x, y, cx, cy, flags)    
  HDWP hdwp; /* handle of internal structure */
  HWND hwnd; /* handle of window to position */
  HWND hwndInsertAfter; /* placement-order handle */
  int x; /* horizontal position, */  
  int y; /* vertical position, */  
  int cx; /* width */
  int cy; /* height */
  UINT flags; /* window-positioning flags, */  

The DeferWindowPos function updates the given internal structure for the given window. The function then returns the handle of the updated structure. The EndDeferWindowPos function uses the information in this structure to change the position and size of a number of windows simultaneously.

Parameters

hdwp

Identifies an internal structure that contains size and position information for one or more windows. This structure is returned by the BeginDeferWindowPos function or by the most recent call to the DeferWindowPos function.

hwnd

Identifies the window for which to store update information in the structure.

hwndInsertAfter

Identifies a window that will precede the positioned window in the Z-order. This parameter must be a window handle, or one of the following values:

Value Meaning

HWND_BOTTOM Places the window at the bottom of the Z-order. If hwnd identifies a topmost window, the window loses its topmost status.
HWND_TOP Places the window at the top of the Z-order.
HWND_TOPMOST Places the window above all non-topmost windows. The window maintains its topmost position even when the window is deactivated.
HWND_NOTOPMOST Repositions the window to the top of all non-topmost windows (that is, behind all topmost windows).

This parameter is ignored if SWP_NOZORDER is set in the flags parameter.

x

Specifies the x-coordinate of the window's upper-left corner.

y

Specifies the y-coordinate of the window's upper-left corner.

cx

Specifies the window's new width.

cy

Specifies the window's new height.

flags

Specifies one of eight possible 16-bit values that affect the size and position of the window. This parameter can be a combination of the following values:

Value Meaning

SWP_DRAWFRAME Draws a frame (defined in the window's class description) around the window.
SWP_HIDEWINDOW Hides the window.
SWP_NOACTIVATE Does not activate the window.
SWP_NOMOVE Retains current position (ignores x and y parameters).
SWP_NOREDRAW Does not redraw changes. If this flag is set, no repainting occurs. This applies to the client area, the non-client area (including the title and scroll bars), and any part of the parent window uncovered as a result of the moved window. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that must be redrawn.
SWP_NOSIZE Retains current size (ignores the cx and cy parameters).
SWP_NOZORDER Retains current ordering (ignores the hwndInsertAfter parameter).
SWP_SHOWWINDOW Displays the window.

Return Value

The return value is a handle of the updated structure if the function is successful. This handle may differ from the one passed to the function as the hdwp parameter and should be passed to the next call to DeferWindowPos or to the EndDeferWindowPos function.

The return value is NULL if insufficient system resources are available for the function to complete successfully and the repositioning process is terminated.

Comments

If a call to DeferWindowPos fails, the application should abandon the window-positioning operation without calling the EndDeferWindowPos function.

If SWP_NOZORDER is not specified, Windows places the window identified by hwnd in the position following the window identified by hwndInsertAfter. If hwndInsertAfter is NULL, Windows places the window identified by hwnd at the top of the list. If hwndInsertAfter is HWND_BOTTOM, Windows places the window identified by hwnd at the bottom of the list.

All coordinates for child windows are relative to the upper-left corner of the parent window's client area.

A window can be made a topmost window either by setting hwndInsertAfter to HWND_TOPMOST and ensuring that SWP_NOZORDER is not set, or by setting a window's Z-order so that it is above any existing topmost windows. When a non-topmost window is made topmost, its owned windows are also made topmost. Its owners are not changed.

If neither SWP_NOACTIVATE nor SWP_NOZORDER is specified (that is, when the application requests that a window be simultaneously activated and placed in the specified Z-order), the value specified in hwndInsertAfter is used only in the following circumstances:

Neither HWND_TOPMOST nor HWND_NOTOPMOST is specified in the hwndInsertAfter parameter.

The window specified in the hwnd parameter is not the active window.

An application cannot activate an inactive window without also bringing it to the top of the Z-order. Applications can change the Z-order of an activated window without restrictions or activate a window and then move it to the top of the topmost or non-topmost windows.

A topmost window is no longer topmost if it is repositioned to the bottom (HWND_BOTTOM) of the Z-order or after any non-topmost window. When a topmost window is made non-topmost, the window and all of its owners, and its owned windows, are also made non-topmost.

A non-topmost window may own a topmost window, but not vice versa. Any window (for example, a dialog box) owned by a topmost window is itself made topmost to ensure that all owned windows stay above their owner.

See Also

BeginDeferWindowPos, EndDeferWindowPos