SetViewportOrgEx
The SetViewportOrgEx function specifies which device point maps to the window origin (0,0).
BOOL SetViewportOrgEx(
HDC hdc, // handle to device context
int X, // new x-coordinate of viewport origin
int Y, // new y-coordinate of viewport origin
LPPOINT lpPoint // original viewport origin
);
Parameters
hdc
[in] Handle to the device context.
X
[in] Specifies the x-coordinate, in device units, of the new viewport origin.
Y
[in] Specifies the y-coordinate, in device units, of the new viewport origin.
lpPoint
[out] Pointer to a POINT structure that receives the previous viewport origin, in device coordinates. If lpPoint is NULL, this parameter is not used.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Windows NT/2000/XP: To get extended error information, call GetLastError.
Remarks
This function (along with SetViewportExtEx and SetWindowExtEx) helps define the mapping from the logical coordinate space (also known as a window) to the device coordinate space (the viewport). SetViewportOrgEx specifies which device point maps to the logical point (0,0). It has the effect of shifting the axes so that the logical point (0,0) no longer refers to the upper-left corner.
//map the logical point (0,0) to the device point (xViewOrg, yViewOrg)
SetViewportOrgEx ( hdc, xViewOrg, yViewOrg, NULL)
This is related to the SetViewportOrgEx function. Generally, you will use one function or the other, but not both. Regardless of your use of SetWindowOrgEx and SetViewportOrgEx, the device point (0,0) is always the upper-left corner.
Example Code
For an example, see Redrawing in the Update Region.
Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.
GetViewportOrgEx
The GetViewportOrgEx function retrieves the x-coordinates and y-coordinates of the viewport origin for the specified device context.
BOOL GetViewportOrgEx(
HDC hdc, // handle to device context
LPPOINT lpPoint // viewport origin
);
Parameters
hdc
[in] Handle to the device context.
lpPoint
[out] Pointer to a POINT structure that receives the coordinates of the origin, in device units.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Windows NT/2000/XP: To get extended error information, call GetLastError.
Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.