CDC的DrawText函数可以很方便进行字符串的显示,DT_WORDBREAK属性可以支持自动换行,但是我发现它只能对汉字进行自动换行,对一般的字符则不予理睬,这是为什么?例如:
pDC->DrawText( "汉字进行自动换行", CRect(0,0,20,20),DT_WORDBREAK );
输出结果为:
汉字
进行
自动
换行
但是pDC->DrawText( "asdasdasdasdasdasd", CRect(0,0,20,20),DT_WORDBREAK );
输出结果则为:
asda
后面的字符给切掉了,为什么??

解决方案 »

  1.   

    如果你能在中间加几个空格就好了,WORDBREAK是把连在一起的英文字母当一个单词的,而且它在显示的时候不截断单词。
      

  2.   

    pDC->DrawText( "asdasdasdasdasdasd", CRect(0,0,20,20),DT_EDITCONTROL Or DT_WORDBREAK );
      

  3.   

    错了
     pDC->DrawText( "asdasdasdasdasdasd", CRect(0,0,20,20),DT_EDITCONTROL | DT_WORDBREAK );
      
      

  4.   

    请主意SetTextAlign要设成默认值,不然会出现怪现象,上次,就这个我调了一晚上!!!
      

  5.   

    这样可以自动换行
    pDC->DrawText( "asdasdasdasdasdasd", CRect(0,0,20,20),DT_LEFT|DT_NOPREFIX|DT_WORDBREAK);
      

  6.   

    Knowledge Base  HOWTO: Fit Text in a RectanglePSS ID Number: Q200262Article Last Modified on 07-8-2002
    --------------------------------------------------------------------------------
    The information in this article applies to: Microsoft Win32 Application Programming Interface (API)
    the operating system: Microsoft Windows XP 
    the operating system: Microsoft Windows 2000 
    the operating system: Microsoft Windows Millennium Edition 
    the operating system: Microsoft Windows 98 Second Edition 
    the operating system: Microsoft Windows 98