c++ - Sharing data between console application and a windows form -


i'm writing program works in console, once in while, need use forms.

i created windows form , switched output console. after that, added 1 more form (form2) project, , have code looks this:

#include "stdafx.h" #include <iostream> // std::cout , such #include "form1.h" #include "form2.h"  using namespace testing_forms;  [stathreadattribute] int main(array<system::string ^> ^args) {     // enabling windows xp visual effects before controls 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; } 

so, basically, program runs 1st instruction block, calls form, runs 2nd instruction block, , on.

however, not allow me share data between forms , console, which, since 1 program, need, such usernames, integers , such.

the way can think of keeping text file , writing/reading to/from console , forms share information (i have not tested this), but, honest, don't solution.

so, how can share data , forth between windows form , console, using (preferably) variables?

there many ways - can use sockets, pipes, message queues, can store information in database, can host wcf service in console application etc.

but won't discussion of of best here. really, if having problem, should make whole solution windows forms/wpf application. it's lot easier pass information between forms of same application, specially if can reference each other amongst themselves. have call each other's methods, or access each other's properties, or go same static class. in same environment, no application boundaries crossed.

if want keep console there, have main form hidden , open separate console app. can feed console relevant text.

food thought.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -