Results 1 to 4 of 4

Thread: [RESOLVED] Convert DrawTextW to .NET DrawString

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    499

    Resolved [RESOLVED] Convert DrawTextW to .NET DrawString

    I have old code using DrawTextW to draw single line. The flags are:

    0x820 = DT_NOPREFIX | DT_SINGLELINE

    But .NET's g.DrawString 'smartly' not draw remaining chars (cut off or use dot) if space is not enough.

    How to g.DrawString exactly as DrawTextW for 'continuous' draw ?
    Attached Images Attached Images  

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    4,321

    Re: Convert DrawTextW to .NET DrawString

    Try NoWrap flag like this

    Code:
    StringFormat format =
        new StringFormat
        {
            FormatFlags = StringFormatFlags.NoWrap,
            Trimming = StringTrimming.None
        };
    g.DrawString(s, font, brush, rect, format);
    cheers,
    </wqw>

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    499

    Re: Convert DrawTextW to .NET DrawString

    Quote Originally Posted by wqweto View Post
    Try NoWrap flag like this

    Code:
    StringFormat format =
        new StringFormat
        {
            FormatFlags = StringFormatFlags.NoWrap,
            Trimming = StringTrimming.None
        };
    g.DrawString(s, font, brush, rect, format);
    cheers,
    </wqw>
    I feel embarrassed...
    I forget the trimming setting.

    thank you.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,066

    Re: Convert DrawTextW to .NET DrawString

    If your issue is resolved, please use the Thread Tools menu to mark the thread Resolved so we know you don't need more help without opening it and reading the whole thing.

Tags for this Thread

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