SetWindowOrg

2.x

  DWORD SetWindowOrg(hdc, nXOrigin, nYOrigin)    
  HDC hdc; /* handle of device context */
  int nXOrigin; /* x-coordinate to map to upper-left window corner */
  int nYOrigin; /* y-coordinate to map to upper-left window corner */

The SetWindowOrg function sets the window origin for the given device context.

Parameters

hdc

Identifies the device context.

nXOrigin

Specifies the logical x-coordinate to map to the upper-left corner of the window.

nYOrigin

Specifies the logical y-coordinate to map to the upper-left corner of the window.

Return Value

The return value is the coordinates of the previous window origin, in logical units, if the function is successful. The low-order word contains the x-coordinate of the previous window origin; the high-order word contains the y-coordinate. Otherwise, the return value is zero.

Comments

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) converts logical coordinates to device coordinates (the viewport). GDI converts logical coordinates to the device coordinates of the viewport in the same way as it converts the origin.

To convert points to the right, an application can specify a negative value for the nXOrigin parameter. Similarly, to convert points down (in the MM_TEXT mapping mode), the nYOrigin parameter can be negative.

Example

The following example uses the CopyMetaFile function to copy a metafile to a specified file, plays the copied metafile, uses the GetMetaFile function to retrieve a handle of the copied metafile, uses the SetWindowOrg function to change the position at which the metafile is played 200 logical units to the right, and then plays the metafile at the new location:

HANDLE hmf, hmfSource, hmfOld;
LPSTR lpszFile1 = "MFTest";

hmf = CopyMetaFile(hmfSource, lpszFile1);
PlayMetaFile(hdc, hmf);
DeleteMetaFile(hmf);

hmfOld = GetMetaFile(lpszFile1);
SetWindowOrg(hdc, -200, 0);
PlayMetaFile(hdc, hmfOld);

DeleteMetaFile(hmfSource);
DeleteMetaFile(hmfOld);

See Also

CopyMetaFile, GetMetaFile, GetWindowOrg, PlayMetaFile, SetViewportOrg