大家好,我在阅读《windows 程序设计》这本书中,作者写道:
1、假设显示区域为cxClient个图素宽和cyClient个图素高。如果想将逻辑点(0,0)定义为显示 区域的中心,可进行如下呼叫:
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SetViewportOrgEx的参数总是使用设备单位。现在,逻辑点(0,0)将映像为设备点(cxClient/2,cyClient/2)。
2、用下面的SetWindowOrgEx叙述可以获得与上面使用SetViewportOrgEx同样的效果:
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;
读到这里,我都能明白,现在作者又写了一句话,这句话我看不明白了,
3、您不会将这两个函数一起用,除非您知道这么做的结果:
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;
这意味着逻辑点(-cxClient/2,-cyClient/2)将映像为设备点(cxClient/2, cyClient/2)
现在请问,为什么第3:将SetViewportOrgEx和SetWindowOrgEx连在一起用,会出现逻辑点(-cxClient/2,-cyClient/2)将映像为设备点(cxClient/2, cyClient/2)这种情况,按照作者第1和第2点来看,
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;这行代码是逻辑点(0,0)将映像为设备点(cxClient/2,cyClient/2)。然后:
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;这行代码是将逻辑点(-cxClient / 2,-cyClient / 2)映像为设备点(0,0),
可是SetViewportOrgEx这行代码不是已经将逻辑点(-cxClient / 2,-cyClient / 2)成为了设备点(0,0)了吗?