{"id":562,"date":"2011-01-06T20:51:59","date_gmt":"2011-01-06T20:51:59","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=562"},"modified":"2022-02-17T06:24:04","modified_gmt":"2022-02-17T06:24:04","slug":"passing-values-between-forms","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/forms\/passing-values-between-forms","title":{"rendered":"Passing values between forms"},"content":{"rendered":"<h4>To Use A Global Variable<\/h4>\n<p>Add it to our ap-main.h file &#8211; this is automatically included in all files (see creating a project if this file is not in your project)<br \/>\nYou can&#8217;t make strings global &#8211; only normal variable types<br \/>\nHowever you can just pass a handle to a string or come other object so the form can read\/write it.<\/p>\n<h4>To Pass Parameters Or Handles To A Form When Its Opened<\/h4>\n<p>In the form constructor change the (void) to be whatever you wannt to pass just like any other function and then in the<\/p>\n<pre><code>\tfrmMyForm ^TheForm = gcnew frmMyForm(MyVariableName);<\/code><\/pre>\n<p>Or, you can add propereties to the form class code that allow you to give information or get information back:-<\/p>\n<pre><code>\r\npublic:\r\n\tproperty String ^PassedValue1;\r\n<\/code><\/pre>\n<h4>To Allow A Main Form To Send Information To An Open Sub Form<\/h4>\n<h5>Instead of the typical way to open a form<\/h5>\n<pre><code>\r\n\tfrmConfiguration ^ConfigForm = gcnew frmConfiguration ();\r\n<\/code><\/pre>\n<h5>Do this to create the form as a normal object<\/h5>\n<p>In the declaraion area of main form define the object:<\/p>\n<pre><code>\r\n\tprivate:\r\n\t\tfrmConfiguration ^ConfigForm;\r\n<\/code><\/pre>\n<p>In the mains forms constructor create the object as global to the form:<\/p>\n<pre><code>\r\n\t\/\/Create sub form objects ready for use\r\n\tConfigForm = gcnew frmConfiguration();\r\n<\/code><\/pre>\n<p>Then in the sub form declarations area create variables you want to be able to write to:<\/p>\n<pre><code>\r\n\tpublic:\r\n\t\tunsigned char DibbaReaderIdentifyReceived;\r\n<\/code><\/pre>\n<p>Then when you want to open the sub form:<\/p>\n<pre><code>\r\n\tConfigForm-&gt;ShowDialog();\r\n<\/code><\/pre>\n<p>Now in the main form you can write to these variables and the sub form can get the values while its running.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To Use A Global Variable Add it to our ap-main.h file &#8211; this is automatically included in all files (see creating a project if this file is not in your project) You can&#8217;t make strings global &#8211; only normal variable types However you can just pass a handle to a string or come other object [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-562","post","type-post","status-publish","format-standard","hentry","category-forms"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/562","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=562"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/562\/revisions"}],"predecessor-version":[{"id":1052,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/562\/revisions\/1052"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}