C++ Forms

torched17

Junior Member
Nov 25, 2012
3
0
0
How do I make a C++ form button run a C++ console program on the click of a button from the form?

So if I have Form1 with just a button called Start on it how can I make it run Game.cpp when button Start is clicked?
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
First of all. Game.CPP is a source file, not an executable.

what you need to do is locate the appropriate command to fire off a batch file in a DOS window or just fire off another executable that happens to be a console vs a UI app.

then in the code that handles the button click and what is needed to accomplish the above.
 

torched17

Junior Member
Nov 25, 2012
3
0
0
ok so what I did instead, because it has to be all c++, was to put the two in their own projects and In the form's button click event do system("path to game.cpp's executable file but it still doesn't open it. Is it trying to open it in the form instead of the console?
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
Hey to use the Create Process function what #include files do I need to use?

Also I'm not quite sure on how to use this and what I put in it. Thanks

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682512(v=vs.85).aspx

Include windows.h

That demo program creates a new command windows and sends it the program's command-line arguments as the command to be executed. You can pretty much follow it verbatim, you just need to change the first parameter of CreateProcess to the path to your .exe, and change the second parameter to NULL (unless you want to send command-line arguments to the program).