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_TABSTOP 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_TABSTOP, 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_TABSTOP 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.
0 comments