19,473
社区成员




case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hDC = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
//映射模式
int iMapMode = SetMapMode(hDC, MM_ANISOTROPIC);
SIZE szViewportExt, szWindowExt;
SetViewportExtEx(hDC, -1, //X轴镜像
-1, //Y轴镜像
&szViewportExt);
SetWindowExtEx(hDC, 1, 1, &szWindowExt);
//坐标原点
POINT ptOrg;
SetViewportOrgEx(hDC, rt.right, rt.bottom, //设置为左下角
&ptOrg);
//绘制代码
MoveToEx(hDC, 0, 0, NULL);
LineTo(hDC, 100, 100);
LineTo(hDC, 100, 0);
//恢复映射模式、坐标轴方向及坐标原点
SetMapMode(hDC, iMapMode);
SetViewportExtEx(hDC, szViewportExt.cx, szViewportExt.cy, NULL);
SetWindowExtEx(hDC, szWindowExt.cx, szWindowExt.cy, NULL);
SetViewportOrgEx(hDC, ptOrg.x, ptOrg.y, NULL);
EndPaint(hWnd, &ps);
break;
}