DWORD SetViewportExt(hDC,X,Y)
This function sets the x- and y-extents of the viewport of the specified device context. The viewport, along with the device-context window, defines how GDI maps points in the logical coordinate system to points in the coordinate system of the actual device. In other words, they define how GDI converts logical coordinates into device coordinates.
The x- and y-extents of the viewport define how much GDI must stretch or compress units in the logical coordinate system to fit units in the device coordinate system. For example, if the x-extent of the window is 2 and the x-extent of the viewport is 4, GDI maps two logical units (measured from the x-axis) into four device units. Similarly, if the y-extent of the window is 2 and the y-extent of the viewport is –1, GDI maps two logical units (measured from the y-axis) into one device unit.
The extents also define the relative orientation of the x- and y-axes in both coordinate systems. If the signs of matching window and viewport extents are the same, the axes have the same orientation. If the signs are different, the orientation is reversed. For example, if the y-extent of the window is 2 and the y-extent of the viewport is –1, GDI maps the positive y-axis in the logical coordinate system to the negative y-axis in the device coordinate system. If the x-extents are 2 and 4, GDI maps the positive x-axis in the logical coordinate system to the positive x-axis in the device-coordinate system.
Parameter | Type/Description |
hDC | HDC Identifies the device context. | |
X | int Specifies the x-extent of the viewport (in device units). | |
Y | int Specifies the y-extent of the viewport (in device units). |
The return value specifies the previous extents of the viewport. The previous y-extent is in the high-order word; the previous x-extent is in the low-order word. When an error occurs, the return value is zero.
When the following mapping modes are set, calls to the SetWindowExt and SetViewportExt functions are ignored:
MM_HIENGLISH
MM_HIMETRIC
MM_LOENGLISH
MM_LOMETRIC
MM_TEXT
MM_TWIPS
When MM_ISOTROPIC mode is set, an application must call the SetWindowExt function before it calls SetViewportExt.