void CWindowsPracticeView::OnDraw(CDC* pDC)
{
CWindowsPracticeDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
HDC hdc = pDC->m_hDC;
// TODO: 在此处为本机数据添加绘制代码
// 第6章 坐标空间和变换
{
// 获得物理设别坐标空间的大小
CWnd *win = pDC->GetWindow();
RECT rect;
GetWindowRect(&rect);
int deW = rect.right - rect.left;
int deH = rect.bottom - rect.top;
// 1. MM_LOMETRIC 每个逻辑单元映射到0.1毫米。正x是向右; 正y向上
/*SetMapMode(hdc, MM_LOMETRIC);
SetWindowOrgEx(hdc, 0, deH, NULL);*/
// 2. MM_TEXT 每个逻辑单元映射到一个设备像素。正x是向右; 正y向下
/*SetMapMode(hdc, MM_TEXT);
SetWindowOrgEx(hdc, 0, 0, NULL);*/
// 3. MM_ANISOTROPIC 逻辑单元映射到具有任意缩放轴的任意单位
/*SetMapMode(hdc, MM_ANISOTROPIC);
SetWindowExtEx(hdc, 1, 1, NULL);
SetWindowOrgEx(hdc, 0, 0, NULL);
SetViewportExtEx(hdc, 1, -1, NULL);
SetViewportOrgEx(hdc, 0, deH, NULL);*/
// 画线
CString str(_T(""));
str.Format(_T("设备坐标空间长度:%d,设备坐标空间宽度:%d"), deW, deH);
TextOut(hdc, 0, 20,
12-30
3075
