Partager via


AdjustWindowRectEx

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function calculates the required size of the rectangle of a window with extended style based on the desired client-rectangle size. The window rectangle can then be passed to the CreateWindowEx function to create a window whose client area is the desired size.

Syntax

BOOL AdjustWindowRectEx( 
  LPRECT lpRect, 
  DWORD dwStyle, 
  BOOL bMenu,
  DWORD dwExStyle 
);

Parameters

  • lpRect
    [in, out] Long pointer to a RECT structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client area.
  • dwStyle
    [in] Specifies the window styles of the window whose required size is to be calculated.
  • bMenu
    [in] Boolean that specifies whether the window has a menu.
  • dwExStyle
    [in] Specifies the extended style of the window whose required size is to be calculated.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Code Example

Here is source code for the function OomUI_CreateOomWindow, which creates and returns a handle to the Out of Memory Window, calling AdjustWindowRectEx in the process.

HWND 
OomUI_CreateOomWindow (void)
{
  DWORD grfStyle, grfExStyle;
  RECT rc;
  grfStyle = WS_BORDER | WS_POPUP | WS_CAPTION | WS_SYSMENU;
  grfExStyle = WS_EX_NODRAG | WS_EX_CAPTIONOKBTN | WS_EX_WINDOWEDGE;
  SetRect (&rc, 0, 0, CX_WINDOW, 194);
  AdjustWindowRectEx (&rc, grfStyle, FALSE, grfExStyle);
  oomui.hwnd = CreateWindowEx (
  grfExStyle,
  v_szClass,
  v_szTitle,
  grfStyle,
  12, 7, 
  rc.right - rc.left, rc.bottom - rc.top, NULL, NULL,
  s_hinst, NULL);
  ASSERT (oomui.hwnd);
  return oomui.hwnd;
}

Remarks

The bMenu parameter must be FALSE; menu bars are not supported.

A client rectangle is the smallest rectangle that completely encloses a client area. A window rectangle is the smallest rectangle that completely encloses the window, which includes the client area and the nonclient area.

When an invalid window style is specified in the dwStyle parameter, the WS_POPUP style is assumed and used for the window calculation. For a description of supported window styles, see CreateWindowEx.

The AdjustWindowRectEx function does not add extra space when a menu bar wraps to two or more rows.

Requirements

Header winuser.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

RECT
Windows Functions