OffsetViewportOrg

2.x

  DWORD OffsetViewportOrg(hdc, nXOffset, nYOffset)    
  HDC hdc; /* handle of device context */
  int nXOffset; /* offset along x-axis, */  
  int nYOffset; /* offset along y-axis, */  

The OffsetViewportOrg function modifies the coordinates of the viewport origin relative to the coordinates of the current viewport origin.

Parameters

hdc

Identifies the device context.

nXOffset

Specifies the value, in device units, to add to the x-coordinate of the current origin.

nYOffset

Specifies the value, in device units, to add to the y-coordinate of the current origin.

Return Value

The low-order word of the return value contains the x-coordinate, in device units, of the previous viewport origin, if the function is successful; the high-order word contains the y-coordinate.

Comments

The viewport origin is the origin of the device coordinate system for a window. By changing the viewport origin, an application can change the way the graphics device interface (GDI) maps points from the logical coordinate system. 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.

Example

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);

See Also

GetViewportOrg, OffsetWindowOrg, SetViewportOrg