SetViewportOrgEx---GDI学习

The SetViewportOrgEx function specifies which device point maps to the window origin (0,0).

总是对这个系列的函数不太清楚,ViewPort(Device Point),WindowPort(Logic Point),这个函数将参数中指定的x,y(设备坐标),映射到Window Origin(0,0),也就是你实用GDI时其坐标原点现在在(x,y)而不是UpLeft。

**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.

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

这个函数与SetViewportExtEx and SetWindowExtEx一起使用使得逻辑坐标映射到相应的设备坐标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 SetWindowOrgEx 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

SetWindowOrgEx可以达到同样的作用,但是通常情况下只应该使用其中的一个(记住),注意:不管是使用SetWindowOrgEx还是SetViewportOrgEx,设备点(0,0)始终是在左上角的。

 

为了以后不在这里纠缠不清,以后都只用这个函数了,现在GDI中的(0,0)现在是(x,y)了