如何获取以毫米 (mm) 为单位的 MFC 视图?

How to get the MFC view in millimeters (mm)?

我必须画一条线,这样——例如——如果线的输入宽度值为 20 毫米,那么绘制的线的宽度应为 20 毫米。我在 MFC 文档中读到,我们提供的输入宽度值被 MFC 视为单位,绘制的对象值以像素为单位。谁能告诉我如何设置和获取以毫米为单位的宽度缩放比例。

您需要使用SetMapMode

The SetMapMode function sets the mapping mode of the specified device context. The mapping mode defines the unit of measure used to transform page-space units into device-space units, and also defines the orientation of the device's x and y axes.

查看MM_LOMETRICMM_HIMETRIC:

Each logical unit is mapped to 0.01 millimeter. Positive x is to the right; positive y is up.

文章底部写着:

The MM_HIENGLISH, MM_HIMETRIC, MM_LOENGLISH, MM_LOMETRIC, and MM_TWIPS modes are useful for applications drawing in physically meaningful units (such as inches or millimeters).