AdjustWindowRectEx (Windows CE 5.0)

Send Feedback

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.

BOOLAdjustWindowRectEx(   LPRECTlpRect,   DWORDdwStyle,   BOOLbMenu,DWORDdwExStyle );

Parameters

  • lpRect
    [in] 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 Values

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

OS Versions: Windows CE 1.0 and later.
Header: Winuser.h.

See Also

RECT | Windows Functions

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.