Note that there are some explanatory texts on larger screens.

plurals
  1. POSharing data between console application and a windows form
    text
    copied!<p>I'm writing a program that works primarily in a console, but once in a while, I need to use forms.</p> <p>I created a windows form and then switched the output to console. After that, I added one more form (Form2) to the project, and now I have code that looks something like this:</p> <pre><code>#include "stdafx.h" #include &lt;iostream&gt; // For std::cout and such #include "Form1.h" #include "Form2.h" using namespace testing_forms; [STAThreadAttribute] int main(array&lt;System::String ^&gt; ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); /* Instructions Block 1 */ Application::Run(gcnew Form1()); /* Instructions Block 2 */ Application::Run(gcnew Form2()); /* Instructions Block 3 */ return 0; } </code></pre> <p>So, basically, the program runs the 1st Instruction Block, then calls a Form, then runs the 2nd Instruction Block, and so on.</p> <p>However, this does not allow me to share data between the forms and the console, which, since it is only one program, I really need, such as usernames, integers and such.</p> <p>The only way I can think of is keeping a text file and writing/reading to/from it from the console and the forms to share the information (I have not tested this), but, to be honest, I don't really like this solution.</p> <p>So, how can I share data back and forth between a windows form and a console, using (preferably) only variables?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload