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.