Dismiss Notice

Register now to be one of the first members of this SharePoint Community! Click here it just takes seconds!

Dismiss Notice
Welcome Guest from Country Flag

Notes on DrawText and tab stops

Discussion in 'Official Microsoft News' started by Raymond Chen - MSFT, Oct 10, 2018.

Thread Status:
Not open for further replies.
  1. Raymond Chen - MSFT

    Raymond Chen - MSFT Guest

    Blog Posts:
    0
    The DrawText function
    will recognize tab characters if you ask for
    DT_EXPANDTABS.



    And then things get weird.



    If you ask for
    DT_EXPANDTABS,
    then you cannot ask for
    any of the
    DT_*_ELLIPSIS features.
    The ellipsis code doesn't support tabs.



    Tab stops default to every eight average character widths.
    If you want to change the default, you can specify
    DT_TABSTOP
    and put the desired number of average characters per tab
    in bits 8 through 15.
    For example, if you want tabs every four average characters,
    you would use
    DT_TABSTOP | 0x0400.



    The
    DT_TABSTOP
    flag precludes you from using any of the flags
    that normally occupy bits 8 through 15,
    since it takes over those bits for its own purposes.
    Specifically, these flags cannot be combined
    with DT_TABSTOP:




    #define DT_NOCLIP 0x00000100

    #define DT_EXTERNALLEADING 0x00000200

    #define DT_CALCRECT 0x00000400

    #define DT_NOPREFIX 0x00000800

    #define DT_INTERNAL 0x00001000

    #define DT_EDITCONTROL 0x00002000

    #define DT_PATH_ELLIPSIS 0x00004000

    #define DT_END_ELLIPSIS 0x00008000





    You can avoid this problem with
    DT_TABSTOPS by
    using DrawTextEx:
    When you use
    using DrawTextEx,
    the tab stop interval is specified by the
    iTabLength member of the
    DRAWTEXTPARAMS structure
    instead of being smuggled inside bits 8 through 15
    of the flags.



    If you do not specify
    DT_TABSTOPS,
    then the value of iTabLength is ignored.



    The tab stop positions are relative to the left edge
    of the formatting rectangle you provided plus any
    left margin.



    If you specify
    DT_TABSTOPS
    but forgot to say
    DT_EXPANDTABS,
    then you don't get tab expansion.
    You went to the effort of configuring something
    you didn't enable.

    Continue reading...
     
Thread Status:
Not open for further replies.

Share This Page

LiveZilla Live Chat Software