Here's how the functions work: If you change the viewport origin to (xViewOrg, yViewOrg), the logical point (0, 0) will be mapped to the device point (xViewOrg, yViewOrg). If you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0), which is the upper left corner. Regardless of any changes you make to the window and viewport origins, the device point (0, 0) is always the upper left corner of the client area.
我的理解是基于这段话的,但是看他最后的结论一下子弄糊涂了。
我的理解是基于这段话的,但是看他最后的结论一下子弄糊涂了。
解决方案 »
- 请教:activex控件只能在开发环境所在的机器上运行
- 请问从cl.exe返回的编译错误如何解决
- 为何 CreateDispatch() 总是失败?
- MFC程序Release模式下运行出错
- 最近学VC好郁闷,迫切高手来帮我开窍呀.帮帮忙了.
- 请问GDI位图和DIB的区别?
- 【请教】如何修改DLL文件名?
- VS2010 MFC PropertyGrid Control 组件 内容刷新时 会出现黑色斑块
- 请问,mfc多文档视图下,要怎么样才能实现下面的界面,是否有相关控件
- VC我不熟,你能帮我解释一下做COM时下面的语句吗:
- 小问题!unsigned short如何转换为注册表中REG_MULTI_SZ类型?
- 没分了,有谁能告诉如何将BOOL类型转换为int;再次先谢谢了
你误会了,我说的0.5就是一半的意思,你也可以理解为50,总之是总长度的1/2。
这个问题和精度无关。是petzold所说的我感觉前后不一致,
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;This means that the logical point (-cxClient/2, -cyClient/2) is mapped to the device point (cxClient/2, cyClient/2),
我认为应该是device point(0,0)
The SetViewportOrgEx function specifies which device point maps to the window origin (0,0).
The SetWindowOrgEx function specifies which window point maps to the viewport origin (0,0).
那么,对于第一个调法,SetViewportOrg,结论很显然
对于第二个调法,SetWindowOrg,参数是负数,也就是把-x,-y放到device coordinates的原点(0,0),而device的(0,0)永远是左上角的那点,MM_TEXT里y是向下为正,那么你向右,向下移动x,y,到屏幕中间,那就是window的原点我以为你说的是后面bitmap里面的一个例子……那个我现在还没搞懂
我也是这样理解阿,但是您看petzold怎么说的:
This means that the logical point (-cxClient/2, -cyClient/2) is mapped to the device point (cxClient/2, cyClient/2)
后来的图片也说明了他认为经过这两个语句以后,窗口的右下角(而不是中间)才是window的原点!
但是他前面的意思应该是中间阿,所以我正是因为这个迷惑阿。
你看一下Section 1 Chapter 5 The GDI Map Mode
This means that the logical point (-cxClient/2, -cyClient/2) is mapped to the device point (cxClient/2, cyClient/2)
这句话我实在无法理解,我认为应该是:
This means that the logical point (-cxClient/2, -cyClient/2) is mapped to the device point (0, 0),这也正是你的观点。
但是要说petzold错了,我有点不敢,:)
你看一下Section 1 Chapter 5 The GDI Map Mode ,看看是否是我理解错误。
不知道你们看到这里的时候有没有同样的想法,他前后说法不一致。
当然,很大的可能性是我理解错误,希望能指出我到底错在那里?
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;This means that the logical point (-cxClient/2, -cyClient/2) is mapped to the device point (cxClient/2, cyClient/2), ......
他说这句话到底指的什么意思????????????
~~~~~~~~~~~~~~~~~~~~~~~~~~
那么他这句话就和msdn的精神不符,:)
谢谢ed9er(始祖鸟)给出的msdn的“圣谕”。
大家应该都有这本书吧,
看看他的讲解
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;这两个函数,只要用一个就能达到效果,两个一起用就叠加效果。windoworg是逻辑原点 viewportorg是设备原点
1。)如果你仅用setWindowOrgEx(...),相当影含了setViewOrgEX(hdc,0,0,NULL)
这两个函数有次序之分的,
必须setViewOrgEx首先调用。
上面的意思是现在你的逻辑点(-cxClient/2,-cyClient/2)被印射成设备点(0,0)
换句话说,如果setViewportOrgEX不是(0,0)那么上句中的设备点也应变成相应的点 我前几天才搞清这问题,也干拢了我好久,希望你能看明白
首先感谢你的回答,如果这样理解的确可以解释通,
但是:petzold明确地说:设备原点(0,0)不变!
Regardless of any changes you make to the window and viewport origins, the device point (0, 0) is always the upper left corner of the client area.
而msdn的解释是:
The SetViewportOrgEx function specifies which device point maps to the window origin (0,0).
The SetWindowOrgEx function specifies which window point maps to the viewport origin (0,0).
而petzold前面也说:
SetViewportOrgEx其实做的是设置逻辑点(0,0)对应的设备点!并不是改变设备原点的函数!
这一点和msdn相符合。