在《Windows程序设计 第5版》上册第五章中介绍了MM_ANISOTROPIC映射方式。P174有这么一小段代码:
SetMapMode(hdc,MM_ANISOTROPIC);
SetWindowExtEx(hdc,1000,1000,NULL);
SetViewportExtEx(hdc,cxClient/2,-cyClient/2,NULL);
SetViewportExtEx(hdc,cxClient/2,cyClient/2,NULL);
这段代码把一个窗口的X和Y轴范围设置为-1000至+1000,SetWindowExtEx是用于设置窗口的逻辑大小。
然而,后面又有这么一段代码:
SetMapMode(hdc,MM_ANISOTROPIC);
SetWindowExtEx(hdc,1,1,NULL);
SetViewportExtEx(hdc,cxChar,cyChar,NULL);
TextOut(hdc,3,2,TEXT("Hello"),5);
照上一段代码的理解,这段代码是把窗口的X和Y轴范围设置为1,可是其实际作用却是将X和Y轴的单位固定。这是怎么回事呢?如果代码把窗口的X、Y轴范围设置为1,那么按照P171面的解释("Windows 98不允许在客户区超越轴的范围之外显示任何东西"),TextOut中的X、Y参数是3和2,已经超越了轴的范围1,怎么还可以显示出Hello呢?(事实上的确可以显示)
难道SetWindowExtEx有两种作用吗(一种是设置范围,一种是固定单位)?
系统又怎么确认程序员到底是设置范围还是要固定单位呢?
谢谢!别人的贴见于:http://topic.csdn.net/t/20030517/21/1798356.html
感觉最后的解答并不对,因为最后的总程序代码中没有32767那一段
SetMapMode(hdc,MM_ANISOTROPIC);
SetWindowExtEx(hdc,1000,1000,NULL);
SetViewportExtEx(hdc,cxClient/2,-cyClient/2,NULL);
SetViewportExtEx(hdc,cxClient/2,cyClient/2,NULL);
这段代码把一个窗口的X和Y轴范围设置为-1000至+1000,SetWindowExtEx是用于设置窗口的逻辑大小。
然而,后面又有这么一段代码:
SetMapMode(hdc,MM_ANISOTROPIC);
SetWindowExtEx(hdc,1,1,NULL);
SetViewportExtEx(hdc,cxChar,cyChar,NULL);
TextOut(hdc,3,2,TEXT("Hello"),5);
照上一段代码的理解,这段代码是把窗口的X和Y轴范围设置为1,可是其实际作用却是将X和Y轴的单位固定。这是怎么回事呢?如果代码把窗口的X、Y轴范围设置为1,那么按照P171面的解释("Windows 98不允许在客户区超越轴的范围之外显示任何东西"),TextOut中的X、Y参数是3和2,已经超越了轴的范围1,怎么还可以显示出Hello呢?(事实上的确可以显示)
难道SetWindowExtEx有两种作用吗(一种是设置范围,一种是固定单位)?
系统又怎么确认程序员到底是设置范围还是要固定单位呢?
谢谢!别人的贴见于:http://topic.csdn.net/t/20030517/21/1798356.html
感觉最后的解答并不对,因为最后的总程序代码中没有32767那一段
窗口大小不可改,但TextOut按逻辑坐标来的,TextOut也不能超过逻辑坐标范围的吧???
请指点一下。。
HDC hdc, // handle to DC
int nXStart, // x-coordinate of starting position
int nYStart, // y-coordinate of starting position
LPCTSTR lpString, // character string
int cbString // number of characters
);hdc
[in] Handle to the device context.
nXStart
[in] Specifies the x-coordinate, in logical coordinates, of the reference point that the system uses to align the string.
nYStart
[in] Specifies the y-coordinate, in logical coordinates, of the reference point that the system uses to align the string.
lpString
[in] Pointer to the string to be drawn. The string does not need to be zero-terminated, since cbString specifies the length of the string.
cbString
[in] Specifies the length of the string pointed to by lpString.
SetWindowExtEx设置的是虚拟坐标系,而不是逻辑坐标系。
TextOut打印的坐标是逻辑坐标系
MM_TEXT下窗口范围(1,1)“不可改变”,可能是特定的情况吧