SetWindowExtEx function (wingdi.h)

The SetWindowExtEx function sets the horizontal and vertical extents of the window for a device context by using the specified values.


BOOL SetWindowExtEx(
  [in]  HDC    hdc,
  [in]  int    x,
  [in]  int    y,
  [out] LPSIZE lpsz


[in] hdc

A handle to the device context.

[in] x

The window's horizontal extent in logical units.

[in] y

The window's vertical extent in logical units.

[out] lpsz

A pointer to a SIZE structure that receives the previous window extents, in logical units. If lpSize is NULL, this parameter is not used.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.


The window refers to the logical coordinate system of the page space. The extent is the maximum value of an axis. This function sets the maximum values for the horizontal and vertical axes of the window (in logical coordinates). When mapping between page space and device space, SetViewportExtEx and SetWindowExtEx determine the scaling factor between the window and the viewport. For more information, see Transformation of Coordinate Spaces.

When the following mapping modes are set, calls to the SetWindowExtEx and SetViewportExtEx functions are ignored:

When MM_ISOTROPIC mode is set, an application must call the SetWindowExtEx function before calling SetViewportExtEx. Note that for the MM_ISOTROPIC mode, certain portions of a nonsquare screen may not be available for display because the logical units on both axes represent equal physical distances.


For an example, see Invalidating the Client Area.


Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wingdi.h (include Windows.h)
Library Gdi32.lib
DLL Gdi32.dll

See also

Coordinate Space and Transformation Functions

Coordinate Spaces and Transformations Overview