关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解
来源:互联网 发布:网络教育公共服务体系 编辑:程序博客网 时间:2024/05/22 13:54
http://blog.csdn.net/lanyzh0909/article/details/6107814
关于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/typecool/archive/2010/09/16/5887367.aspx
http://www.ucancode.net/faq/Coordinate-SetViewportOrg-SetWindowExt-SetViewportExt-SetMapMode.htm
- 关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解
- 关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解
- 关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解 .
- 关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解
- 关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解
- Windows 程序设计 SetWindowExtEx SetViewportExtEx SetWindowOrgEx SetViewportOrgEx
- SetWindowExtEx函数、SetViewportExtEx函数和SetWindowOrgEx函数
- 关于SetWindowOrgEx和SetViewPortOrgEx之区别
- 转 关于SetViewPortOrgEx与SetWindowOrgEx
- 关于SetWindowOrgEx与SetViewportOrgEx的用法
- 关于MM_ANISOTROPIC映射模式, 利用SetWindowExtEx和SetViewportExtEx函数设置Y轴方向的问题
- SetViewPortOrgEx与SetWindowOrgEx
- SetWindowOrgEx 与 SetViewportOrgEx
- SetWindowExtEx()与SetViewportExtEx()
- 特别篇-SetWindowExtEx,SetViewportExtEx解析
- windows编程中关于设置映象模式的四个函数SetWindowOrg SetViewPortOrg SetMapMode SetWindowExtEx SetViewPortExtEx
- windows编程中关于设置映象模式的四个函数SetWindowOrg SetViewPortOrg SetMapMode SetWindowExtEx SetViewPortExtEx .
- 对windows区域(Region)的操作,不受SetWindowExtEx和SetViewportExtEx的影响
- android 不休眠不锁屏
- JAVA--Set,List,Map的区别
- hlist_head和list_head区别以及container_of机制 - [linux内核]
- 为磁盘目录授权出现:malloc: *** error for object xx: pointer being freed was not allocate问题解决
- windows 2003 VPN服务器配置
- 关于SetWindowOrgEx、SetViewportOrgEx、SetViewportExtEx 和SetWindowExtEx 详解
- HDOJ 1042 N!
- 高效加载大图片
- ofstream的使用方法
- 关于android的theme
- VS2010 IDE 如何解决未经处理的win32异常
- cookie 工具类
- 转android的UI设计九
- 提取字符串或一段文本中的手机号码