CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    116

    DrawText word wrap

    Hi,
    I'm looking for the formatting option parameters necessary in DrawText or DrawTextEx to wrap a long filename properly.

    My static control that Im drawing the text in is large enough...but there are rarely spaces in the filename, so the only alternative Ive managed is ellipses. Id prefer the text to go to the next line.
    DT_WORDBREAK only breaks lines between words.

    Thx.

  2. #2
    Join Date
    Jul 2004
    Posts
    23
    I'm looking at the DirectX SDK for the documentation of ID3DXFont:rawText (which is just a wrapper for GDI's DrawText). I had this very issue with the ID3DXFont variant of this function.

    What did I do to remedy it? I calculated when my string would be extending past the edge of the rect and inserted the newline character in the place of the first character that would break the edge of the rect.

    Worked like a charm for me.

    Edit: Whoops. Just remembered something:

    To keep it left-justified I also checked to see if the next character after my inserted newline character was a space and removed it. (Just incase you actually break on a word).
    Last edited by Darnit; August 18th, 2004 at 04:01 PM.

  3. #3
    Join Date
    Dec 2017
    Posts
    1

    Re: DrawText word wrap

    just use DT_WORDBREAK|DT_EDITCONTROL in DrowText format

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: DrawText word wrap

    Quote Originally Posted by basharbm View Post
    just use DT_WORDBREAK|DT_EDITCONTROL in DrowText format
    Very "actual" answer for the more than 13 years old thread!
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured