Quantcast
Channel: MSDN Blogs
Viewing all articles
Browse latest Browse all 35736

Notes on DrawText and tab stops

$
0
0


The Draw­Text function
will recognize tab characters if you ask for
DT_EXPAND­TABS.



And then things get weird.



If you ask for
DT_EXPAND­TABS,
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_TAB­STOP
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_TAB­STOP | 0x0400.



The
DT_TAB­STOP
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_TAB­STOP:



#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_TAB­STOPS by
using Draw­Text­Ex:
When you use
using Draw­Text­Ex,
the tab stop interval is specified by the
iTabLength member of the
DRAW­TEXT­PARAMS structure
instead of being smuggled inside bits 8 through 15
of the flags.



If you do not specify
DT_TAB­STOPS,
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_TAB­STOPS
but forgot to say
DT_EXPAND­TABS,
then you don't get tab expansion.
You went to the effort of configuring something
you didn't enable.


Viewing all articles
Browse latest Browse all 35736

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>