DWORD OffsetWindowOrg(hdc, nXOffset, nYOffset) | |||||
HDC hdc; | /* handle of device context | */ | |||
int nXOffset; | /* offset along x-axis, */ | ||||
int nYOffset; | /* offset along y-axis, */ |
The OffsetWindowOrg function modifies the window origin relative to the coordinates of the current window origin.
hdc
Identifies the device context.
nXOffset
Specifies the value, in logical units, to add to the x-coordinate of the current origin.
nYOffset
Specifies the value, in logical units, to add to y-coordinate of the current origin.
The low-order word of the return value contains the logical x-coordinate of the previous window origin, if the function is successful; the high-order word contains the logical y-coordinate.
The window origin is the origin of the logical coordinate system for a window. By changing the window origin, an application can change the way the graphics device interface (GDI) maps logical points to the physical coordinate system (the viewport). GDI maps all points in the logical coordinate system to the viewport in the same way as it maps the origin.
To map points to the right, specify a negative value for the nXOffset parameter. Similarly, to map points down (in the MM_TEXT mapping mode), specify a negative value for the nYOffset parameter.
The following example uses the OffsetWindowOrg and OffsetViewportOrg functions to reposition the output of the PlayMetaFile function on the screen:
HDC hdcMeta;
HANDLE hmf;
hdcMeta = CreateMetaFile((LPSTR) NULL);
.
. /* Record the metafile. */
.
PlayMetaFile(hdc, hmf);
OffsetWindowOrg(hdc, -200, -200);
PlayMetaFile(hdc, hmf); /* MM_TEXT screen output +200 x, +200 y */
OffsetViewportOrg(hdc, 0, -200);
PlayMetaFile(hdc, hmf); /* outputs -200 y from last PlayMetaFile */
DeleteMetaFile(hmf);