请问pDC->DrawText("aaaaaaaaaaaaaaaaaaaa",StrRect,DT_WORDBREAK),当显示的内容长度大于StrRect.Width()时,为什么不能分行显示?请问要如何做?

解决方案 »

  1.   

    pDC->DrawText("aaaaaaaaaaaaaaaaaaaa",StrRect,DT_WORDBREAK|DT_CALCRECT),
    这样行不行?
      

  2.   

    DrawText好像就是不能自动换行的,从名字就能猜出大半。
    自己计算长度,然后分行输出把。
    不过刚才查了一下你可以用DrawTextEx试试,因为有下面来自msdn的参考:
    It formats text by expanding tabs into appropriate spaces, aligning text to the left, right, or center of the given rectangle, and breaking text into lines that fit within the given rectangle. The type of formatting is specified by nFormat and lpDTParams. For more information, see CDC::DrawText and DrawTextEx in the Platform SDK.
      

  3.   

    需要自己计算长度,在超出地方加回车,DrawText只是在给定的场景上画画
      

  4.   

    pDC->DrawText("aaaaaa aaaaaaaa aaaaaa",StrRect,DT_WORDBREAK);
      

  5.   

    http://search.csdn.net/Expert/topic/469/469304.xml?temp=.9528925
      

  6.   

    pDC->DrawText("aaaaaa\naaaaaaaa\naaaaaa",StrRect,DT_WORDBREAK);