D
doxpix
Unregistered / Unconfirmed
GUEST, unregistred user!
老脸不要了,决定不耻"上"问!!!<br><br>GetTextExtentExPoint具体用来干什么的?<br>怎么用?越具体越生动越好(好像你就像在给小学生上课),有实例最棒。<br><br>--英文说明-----------------------------------------------------------------------<br>The GetTextExtentExPoint function retrieves the number of characters in <br>a specified string that will fit within a specified space and fills <br>an array with the text extent for each of those characters. <br>(A text extent is the distance between the beginning of the space <br>and a character that will fit in the space.) This information is useful <br>for word-wrapping calculations. <br><br>BOOL GetTextExtentExPoint(<br><br> HDC hdc, // handle of device context <br> LPCTSTR lpszStr, // address of character string <br> int cchString, // number of characters in string <br> int nMaxExtent, // maximum width for formatted string <br> LPINT lpnFit, // address of value specifying max. number of chars. <br> LPINT alpDx, // address of array for partial string widths <br> LPSIZE lpSize // address of structure with string dimensions <br> <br> <br><br>Parameters<br><br>hdc<br><br>Identifies the device context. <br><br>lpszStr<br><br>Points to the null-terminated string for which extents are to be retrieved. <br><br>cchString<br><br>Specifies the number of bytes in the string pointed to by the lpszStr parameter. <br><br>nMaxExtent<br><br>Specifies the maximum allowable width, in logical units, of the formatted string.<br> <br><br>lpnFit<br><br>Points to an integer to receive a count of the maximum number of characters <br>that will fit in the space specified by the nMaxExtent parameter. When the <br>lpnFit parameter is NULL, the nMaxExtent parameter is ignored. <br><br>alpDx<br><br>Points to an array of integers to receive partial string extents. <br>Each element in the array gives the distance, in logical units, <br>between the beginning of the string and one of the characters <br>that fits in the space specified by the nMaxExtent parameter. <br>Although this array should have at least as many elements as <br>characters specified by the cchString parameter, the function fills <br>the array with extents only for as many characters as are given <br>by the lpnFit parameter. If alpDx is NULL, the function does not <br>compute partial string widths. <br><br>lpSize<br><br>Points to a SIZE structure that contains the dimensions of the string, <br>in logical units when the function returns. This value cannot be NULL. <br><br> <br><br>Return Values<br><br>If the function succeeds, the return value is nonzero.<br>If the function fails, the return value is zero. To get extended error <br>information, call GetLastError. <br><br>Remarks<br><br>If both the lpnFit and alpDx parameters are NULL, calling the <br>GetTextExtentExPoint function is equivalent to calling the <br>GetTextExtentPoint function. <br><br>See Also<br><br>GetTextExtentPoint, SIZE <br>---------------------------------------------------------------------------------<br><br>--中文说明(翻译地不太好)---------------------------------------------------------<br> 函数功能:该函数取得一个指定字符串里的字符数,该字符串将符合一个指定的空间,<br>并且将其中每一个字符的范围放入一个数组。(一个正文的范围是指空间开始处到一个<br>字符的间距)。此函数对自动换行的计算非常有用。<br><br> 函数原型:BOOL GetTextExtentPoint(HDC hdc, LPCTSTR lpszStr, int cchString, <br> int nMaxExten, LPINT lpnFit, LPINT alpDx, LPSIZE lpSize);<br><br> 参数:<br><br> hdc:设备环境句柄。<br><br> lpszStr:指向以/0(Null)结束的字符串的指针,函数取得该字符中的范围。<br><br> cchString:指定由lpszStr指向的字符串的字节数。<br><br> nMaxExtent:为格式经的字符串指定最大可允许的逻辑单位宽度。<br><br> lpnFit:指向整数的指针,该整数用于接收符合指定范围的字符的最大个数,<br>该范围由nMaxExtent指定。如果lpnFit为NULL,则nMaxExtent无效。<br><br> alpDx:指向整数数组的指针,该数组用于接收部分字符串范围。此数组的<br>每一个元素给出一个间隔值,(按逻辑单位),表示字符串的开始处和在由nMaxExtent<br>指定的空间里的一个字符之间的距离。尽管此数组应当至少有cchString指定那么多个<br>元素,但函数向数组中填入其范围的字符数却由lpnFit确定。如果alpDx为NULL,<br>则函数不计算局部字符串宽度。<br><br> lpSize:指向结构SIZE的指针,该结构在函数返回时含有字符串的尺寸(按逻辑单位)。<br><br> 返回值:如果函数调用成功,返回值非零,如果函数调用失败,返回值是0。<br><br> Windows NT:若想获得更多错误信息,请调用GetLastError函数。<br><br> 备注:如果lpnFit和alpDx的值均为NULL,则调用GetTextExtentPoint等同于<br>调用GetTextExtentExPoint。<br><br> Windows CE:cchString指定由lpszStr指向的字符串的字符个数而不是字节数。<br>在Windows桌面平台下也是如此。<br><br> 速查:Windows NT:3.1及以上版本;Windows:95及以上版本;<br>Windows CE:1.0及以上版本;头文件:wingdi.h;库文件:gdi32.lib;<br>Unicode:在Windows NT环境下实现为Unicode和ANSI两种版本。<br>---------------------------------------------------------------------------------