【转载】关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解
2020-12-13 15:30
                         标签:blog   http   ar   使用   sp   art   log   代码   bs    关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解   1、  SetWindowOrgEx是设置窗口的原点坐标。   例如:          Ellipse(hdc,-100,-100,100,100);          MoveToEx(hdc,-200,0,NULL);          LineTo(hdc,200,0);          MoveToEx(hdc,0,-200,NULL);          LineTo(hdc,0,200);          MoveToEx(hdc,0,0,NULL);          LineTo(hdc,100,100); 运行程序的效果为:   修一下程序为:          SetWindowOrgEx(hdc,-100,-100,NULL);          Ellipse(hdc,-100,-100,100,100);          MoveToEx(hdc,-200,0,NULL);          LineTo(hdc,200,0);          MoveToEx(hdc,0,-200,NULL);          LineTo(hdc,0,200);          MoveToEx(hdc,0,0,NULL);          LineTo(hdc,100,100); 运行效果为:   得出结论:SetWindowOrgEx是设置窗口原点坐标的大小   2、  SetViewportOrgEx设置视口原点坐标。 我们将上面程序再次修改一下:          SetViewportOrgEx (hdc,100,100,NULL);          Ellipse(hdc,-100,-100,100,100);          MoveToEx(hdc,-200,0,NULL);          LineTo(hdc,200,0);          MoveToEx(hdc,0,-200,NULL);          LineTo(hdc,0,200);          MoveToEx(hdc,0,0,NULL);          LineTo(hdc,100,100); 效果很上面的一样:          得出结论:SetViewPortOrgEx是设视口原点坐标的大小,也就是客户区的原点大小。在默认的情况下,客户区的原点为左上角坐标为(0,0)。调用SetViewportOrgEx (hdc,100,100,NULL)就把客户的原点坐标设置为(100,100),那么原来客户区的左上角的坐标就变为了(-100,-100)(在映射模式为MM_TEXT时)。 3、 SetWindowExtEx,  用于设置逻辑坐标范围。 SetViewPortExtEx, 用于设置设备坐标范围。 注意:1、上面的两个函数的调用,只有在映射模式为MM_ANISOTROPIC 和MM_ISOROPIC下才有作用,在其他的模式下将被忽略。 2、             必须在调用SetViewPortExtEx之前调用SetWindowExtEx,以便最有效地使用显示区域中的空间。 修改上面的代码:            SetMapMode(hdc,MM_ANISOTROPIC);          SetWindowExtEx(hdc,200,200,NULL);//将窗口的逻辑坐标X轴0 到200,Y轴设置为0 到200          //将视口原点设置为客户区的中心点上          SetViewportOrgEx(hdc,rectClient.right / 2,rectClient.bottom / 2,NULL);          //将窗口的设备坐标X轴 0 到 rectClient.right,Y轴0 到 rectClient.bottom          SetViewportExtEx(hdc,rectClient.right,rectClient.bottom,NULL);            Ellipse(hdc,-100,-100,100,100);          MoveToEx(hdc,-200,0,NULL);          LineTo(hdc,200,0);          MoveToEx(hdc,0,-200,NULL);          LineTo(hdc,0,200);          MoveToEx(hdc,0,0,NULL);          LineTo(hdc,100,100); 效果图为:         原文地址:http://blog.csdn.net/lanyzh0909/article/details/6107814   【转载】关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解 标签:blog   http   ar   使用   sp   art   log   代码   bs    原文地址:http://www.cnblogs.com/919czzl/p/4075331.html



下一篇:HTML和CSS的复习总结
文章标题:【转载】关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解
文章链接:http://soscw.com/essay/35196.html