{"id":265,"date":"2010-06-22T12:36:55","date_gmt":"2010-06-22T12:36:55","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=265"},"modified":"2022-02-17T06:24:05","modified_gmt":"2022-02-17T06:24:05","slug":"using-text-boxes","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/text-box\/using-text-boxes","title":{"rendered":"Using Text Boxes"},"content":{"rendered":"<h4>Update Settings After A Text Box Is Edited<\/h4>\n<p>Use the &#8216;Leave&#8217; event<\/p>\n<h4>Locking the contents of a text box<\/h4>\n<p>ReadOnly = True<br \/>\nBackColour = Window (if you don&#8217;t want it greyed out)<\/p>\n<h4>Read the contents of a text box<\/h4>\n<p>String ^buffer;<br \/>\nbuffer = txtScreenContents-&gt;Text;<\/p>\n<h4>Write to a text box<\/h4>\n<p>txtScreenContents-&gt;Text = \u201cHello World\\r\\nHeres another line.\u201d<\/p>\n<h4>Multi lines<\/h4>\n<p>Use the \\r\\n characters to insert a line break.<\/p>\n<pre><code>\r\n\ttxtOutput-&gt;Text = \"Name: \" + dir-&gt;FullName + \"\\r\\n\";\r\n\ttxtOutput-&gt;Text += \"Created: \" + CreationTime;\r\n<\/code><\/pre>\n<h4>Scrolling text box<\/h4>\n<pre><code>\r\n\ttxtHistory-&gt;SelectionStart = txtHistory-&gt;TextLength;\t\/\/Set cursor to end of the text box\r\n\ttxtHistory-&gt;ScrollToCaret();\t\t\t\t\/\/Scroll the text box to the cursor position\r\n<\/code><\/pre>\n<h4>Disable right click menu<\/h4>\n<p>Set shortcuts enabled property to false<\/p>\n<h4>Columns Of Text<\/h4>\n<p>Does the UseTabStops property work for text boxes?<br \/>\nUseCustomTabOffsets, CustomTabOffsets may be used for custom defined tab positions<\/p>\n<h4>Stopping The Contents Of A Text Box Being Selectable<\/h4>\n<p>See forms &gt; <a href=\"https:\/\/ibex.tech\/visualcpp\/programming\/visual-cpp-cli-dot-net\/forms\/focus\">Focus<\/a><\/p>\n<h4>Select All Of Text<\/h4>\n<pre><code>\r\n\ttxtOutput-&gt;SelectAll();\r\n<\/code><\/pre>\n<h4>Copy Text<\/h4>\n<pre><code>\r\n\ttxtOutput-&gt;Copy();\r\n<\/code><\/pre>\n<h4>Resizing To Fit The Text<\/h4>\n<pre><code>\r\n\t\/\/Resize to fit the text\r\n\tSystem::Drawing::Size ^TextSize = TextRenderer::MeasureText(txtMyTextBox-&gt;Text, txtMyTextBox-&gt;Font);\r\n\ttxtMyTextBox-&gt;Width = TextSize-&gt;Width;\r\n\ttxtMyTextBox-&gt;Height = TextSize-&gt;Height;\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Update Settings After A Text Box Is Edited Use the &#8216;Leave&#8217; event Locking the contents of a text box ReadOnly = True BackColour = Window (if you don&#8217;t want it greyed out) Read the contents of a text box String ^buffer; buffer = txtScreenContents-&gt;Text; Write to a text box txtScreenContents-&gt;Text = \u201cHello World\\r\\nHeres another line.\u201d [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-265","post","type-post","status-publish","format-standard","hentry","category-text-box"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=265"}],"version-history":[{"count":7,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/265\/revisions"}],"predecessor-version":[{"id":1114,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/265\/revisions\/1114"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}