{"id":94635,"date":"2016-11-03T07:00:00","date_gmt":"2016-11-03T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=94635"},"modified":"2019-03-13T10:33:19","modified_gmt":"2019-03-13T17:33:19","slug":"20161103-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20161103-00\/?p=94635","title":{"rendered":"Solving the problem instead of answering the question: How do I get this RichEdit control to look just like a static control?"},"content":{"rendered":"<p>A customer had a dialog box with two large text controls. Something like this: <\/p>\n<pre>\nIDD_DIALOG_WELCOME DIALOGEX 0, 0, 305, 280  \nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU  \nFONT 8, \"MS Shell Dlg\", 400, 0, 0x0  \n\nBEGIN  \nICON   IDI_MAIN, -1, 0, 0\nLTEXT  \"Contoso Deluxe 2.0\", 10, 0, 300, 24\nLTEXT  \"Check out all the new stuff in this version.\",\n       -1, 13, 17, 290, 20  \nICON   IDI_WHATSNEW_EFFECTS, -1, 13, 45\nLTEXT  \"New effects\", -1, 43, 45, 270, 20  \nLTEXT  \"The super-blaster effect now blasts twice as \\\nmuch as the old blaster. Blast away with all your might!\",\n       -1, 43, 60, 225, 50  \nICON   IDI_WHATSNEW_STYLES, -1, 13, 115\nLTEXT  \"New styles\", -1, 43, 115, 240, 20  \nCONTROL  \"\", IDC_WHATSNEW_STYLES_PLACEMENT, \"Static\",\n       SS_OWNERDRAW, 43, 131, 225, 87\nEND  \n<\/pre>\n<p>The &#8220;super-blaster&#8221; text is rather long, but at least it fits under 255 characters, which is the limit for static text controls. The text that goes into the <code>IDC_WHATS&shy;NEW_STYLES_PLACEMENT<\/code> control is longer than 255 characters, so the dialog creates a RichEdit control at runtime, places it where the <code>IDC_WHATS&shy;NEW_STYLES_PLACEMENT<\/code> control goes, and fills the RichEdit with the required text. <\/p>\n<p>The problem the customer had was that no matter how hard they tried, they couldn&#8217;t get the RichEdit control to look the same as the static text control. In particular, they couldn&#8217;t get the line spacing to match up, which results in an ugly inconsistency within the dialog box. <\/p>\n<p>Their question was &#8220;How do I get this RichEdit control to look just like a static control?&#8221; <\/p>\n<p>This is another case of <a HREF=\"http:\/\/www.perlmonks.org\/?node=XY+Problem\">an XY problem<\/a>. The customer has a problem X: &#8220;I have some text that is too long to go into a static control.&#8221; And the customer has an idea for a solution Y: &#8220;I know! I&#8217;ll use a RichEdit control instead of a static control, and then I&#8217;ll make the RichEdit control visually indistinguishable from a static control.&#8221; The customer then asks for help with Y, when their real problem is X. <\/p>\n<p>Fortunately, since the customer explained their entire scenario, we got to see what X is, and the solution to X doesn&#8217;t involve a RichEdit control at all. <\/p>\n<p>What the customer can do is change the last  control to a plain text control: <\/p>\n<pre>\nLTEXT  \"\", IDC_WHATSNEW_STYLES_TEXT,\n       43, 131, 225, 87\n<\/pre>\n<p>And then instead of creating a RichEdit control at runtime, positioning it, and filling it with text, they simply fill the <code>IDC_WHATS&shy;NEW_STYLES_TEXT<\/code> with the text. <\/p>\n<p>The 255-character limit the customer observed is a limit of the resource compiler, not a limit of the static text control itself. The static text control will take as much text as you give it. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>That&#8217;s not your problem.<\/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-94635","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>That&#8217;s not your problem.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/94635","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=94635"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/94635\/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=94635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=94635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=94635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}