{"id":99935,"date":"2018-10-10T07:00:00","date_gmt":"2018-10-10T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=99935"},"modified":"2019-03-13T00:21:55","modified_gmt":"2019-03-13T07:21:55","slug":"20181010-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20181010-00\/?p=99935","title":{"rendered":"Notes on DrawText and tab stops"},"content":{"rendered":"<p>The <code>Draw&shy;Text<\/code> function will recognize tab characters if you ask for <code>DT_<\/code><code>EXPAND&shy;TABS<\/code>. <\/p>\n<p>And then things get weird. <\/p>\n<p>If you ask for <code>DT_<\/code><code>EXPAND&shy;TABS<\/code>, then you cannot ask for any of the <code>DT_<\/code><code>*_<\/code><code>ELLIPSIS<\/code> features. The ellipsis code doesn&#8217;t support tabs. <\/p>\n<p>Tab stops default to every eight average character widths. If you want to change the default, you can specify <code>DT_<\/code><code>TAB&shy;STOP<\/code> 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 <code>DT_<\/code><code>TAB&shy;STOP | 0x0400<\/code>. <\/p>\n<p>The <code>DT_<\/code><code>TAB&shy;STOP<\/code> 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 <code>DT_<\/code><code>TAB&shy;STOP<\/code>: <\/p>\n<pre>\n#define DT_NOCLIP                   0x00000100\n#define DT_EXTERNALLEADING          0x00000200\n#define DT_CALCRECT                 0x00000400\n#define DT_NOPREFIX                 0x00000800\n#define DT_INTERNAL                 0x00001000\n#define DT_EDITCONTROL              0x00002000\n#define DT_PATH_ELLIPSIS            0x00004000\n#define DT_END_ELLIPSIS             0x00008000\n<\/pre>\n<p>You can avoid this problem with <code>DT_<\/code><code>TAB&shy;STOP<\/code> by using <code>Draw&shy;Text&shy;Ex<\/code>: When you use using <code>Draw&shy;Text&shy;Ex<\/code>, the tab stop interval is specified by the <code>iTabLength<\/code> member of the <code>DRAW&shy;TEXT&shy;PARAMS<\/code> structure instead of being smuggled inside bits 8 through 15 of the flags. <\/p>\n<p>If you do not specify <code>DT_<\/code><code>TAB&shy;STOP<\/code>, then the value of <code>iTabLength<\/code> is ignored. <\/p>\n<p>The tab stop positions are relative to the left edge of the formatting rectangle you provided plus any left margin. <\/p>\n<p>If you specify <code>DT_<\/code><code>TAB&shy;STOP<\/code> but forgot to say <code>DT_<\/code><code>EXPAND&shy;TABS<\/code>, then you don&#8217;t get tab expansion. You went to the effort of configuring something you didn&#8217;t enable. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can ask, but then you can&#8217;t ask for other things, unless you ask a different way.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-99935","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>You can ask, but then you can&#8217;t ask for other things, unless you ask a different way.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=99935"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99935\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=99935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=99935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=99935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}