First, the basic concept of mapping mode
The mapping mode is a Device Description table property that determines how the logical coordinate value is converted to the device coordinate value. The logical coordinate value that is passed to the CDC output function. The device coordinate value refers to the corresponding pixel point position in the window.
Mm_text is the default mapping mode and can be called Cdc::setmapmode () if other mapping modes are used.
1 DC. Setmapmode (mm_lometric); 2 // Do some drawing
Windows supports 8 different mapping modes, with the following attributes:
Note: If you draw a 100-unit-long line in mm_loenglish mapping mode, it may not be exactly 1 inches long. The reason is that Windows does not know the physical resolution (DPI) of the Monitor, which is the number of points that the monitor can display in the horizontal or vertical direction of each inch.
Second, moving the origin point
1. Cdc::setwindoworg (), moves the window origin and processes the logical coordinate values. Cdc::setviewportorg (), moves the viewport origin, and processes the device coordinate values.
2. setwindoworg (x, y), moving the window origin to (x, y) is equivalent to telling Windows to map a logical point (x, y) to a device point (0, 0).
3. setviewportorg (x, y), moving the viewport origin to (x, y) is equivalent to telling Windows to map a logical point (0, 0) to a device point (x, y).
1 cclientdc DC (this); 2 DC. Setmapmode (mm_text); 3 DC. SetWindowOrg (CPoint ()); 4 DC. Rectangle (CRect ());
MFC Drawing Control-mapping mode