CDC::SetViewportExt
virtual CSize SetViewportExt( int cx, int cy );
virtual CSize SetViewportExt( SIZE size );
Return Value
The previous extents of the viewport as a CSize object. When an error occurs, the x- and y-coordinates of the returned CSize object are both set to 0.
Parameters
cx
Specifies the x-extent of the viewport (in device units).
cy
Specifies the y-extent of the viewport (in device units).
size
Specifies the x- and y-extents of the viewport (in device units).
Remarks 设置x,y轴坐标的方向和坐标系包含的范围(单位为像素)
Sets the x- and y-extents of the viewport of the device context. The viewport, along with the device-context window, defines how GDI maps points in the logical coordinate system to points in the coordinate system of the actual device. In other words, they define how GDI converts logical coordinates into device coordinates.
When the following mapping modes are set, calls to SetWindowExt and SetViewportExt are ignored:
CDC::SetWindowExt
virtual CSize SetWindowExt( int cx, int cy );
virtual CSize SetWindowExt( SIZE size );
Return Value
The previous extents of the window (in logical units) as a CSize object. If an error occurs, the x- and y-coordinates of the returned CSize object are both set to 0.
Parameters
cx
Specifies the x-extent (in logical units) of the window.
cy
Specifies the y-extent (in logical units) of the window.
size
Specifies the x- and y-extents (in logical units) of the window.
Remarks 设置坐标系逻辑单位
Sets the x- and y-extents of the window associated with the device context. The window, along with the device-context viewport, defines how GDI maps points in the logical coordinate system to points in the device coordinate system.
When the following mapping modes are set, calls to SetWindowExt and SetViewportExt functions are ignored:
- MM_HIENGLISH
- MM_HIMETRIC
- MM_LOENGLISH
- MM_LOMETRIC
- MM_TEXT
- MM_TWIPS
When MM_ISOTROPIC mode is set, an application must call the SetWindowExt member function before calling SetViewportExt.
CDC::SetViewportOrg
virtual CPoint SetViewportOrg( int x, int y );
virtual CPoint SetViewportOrg( POINT point );
Return Value
The previous origin of the viewport (in device coordinates) as a CPoint object.
Parameters
x
Specifies the x-coordinate (in device units) of the origin of the viewport. The value must be within the range of the device coordinate system.
y
Specifies the y-coordinate (in device units) of the origin of the viewport. The value must be within the range of the device coordinate system.
point
Specifies the origin of the viewport. The values must be within the range of the device coordinate system. You can pass either a POINT structure or a CPoint object for this parameter.
Remarks
Sets the viewport origin of the device context. The viewport, along with the device-context window, defines how GDI maps points in the logical coordinate system to points in the coordinate system of the actual device. In other words, they define how GDI converts logical coordinates into device coordinates.
The viewport origin marks the point in the device coordinate system to which GDI maps the window origin, a point in the logical coordinate system specified by the SetWindowOrg member function. GDI maps all other points by following the same process required to map the window origin to the viewport origin. For example, all points in a circle around the point at the window origin will be in a circle around the point at the viewport origin. Similarly, all points in a line that passes through the window origin will be in a line that passes through the viewport origin.