DrawText显示汉字,显示用截断的方式显示,如何能获取实际显示了多少字符呢,因为汉字和标点符号的宽度不一样,所以没办法用字符宽度的方式计算。
是在实现打印功能中遇到的,如果显示不全,则剩下的部分在第二页的相应行显示

解决方案 »

  1.   

    try
    MeasureString    
      

  2.   

    如果是MeasureString的话,是计算字符串的宽度,如果超过举行宽度了,去掉一个字符再计算宽度看看是否超过矩形宽度,这样效率就差一些了,因为是报表打印,可能会有很多行,每行的这个单元格都这么计算可能效率就接受不了了
      

  3.   

    这个网址的网友远帆有一些解释,但是我不是太明白http://www.delphibbs.com/delphibbs/dispq.asp?lid=348095远帆:应设置对 Textout、Exttextout 等函数的跟踪,然后向系统发
    出 WM_paint 消息,就可以得到字符串的内容。(我也没试过)  
      

  4.   

    DrawText 可以设置自动换行 DT_WORDBREAKBreaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the lpRect parameter. A carriage return-line feed sequence also breaks the line. 
    If this is not specified, output is on one line.