Opening a console window from a Windows form project
-
Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project? For example, I have a typical GUI interface and would like the option to use a command line interface instead. Using cout/cin does not work because there is no console window to output to or input from. How do I open this window without having to create a completely separate Win32 Console application? kialmur
-
Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project? For example, I have a typical GUI interface and would like the option to use a command line interface instead. Using cout/cin does not work because there is no console window to output to or input from. How do I open this window without having to create a completely separate Win32 Console application? kialmur
kialmur wrote:
Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
-
kialmur wrote:
Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
-
Is there no way that I can just open a console and use cout/cin? No forms are open at this point. It seems like quite a complex process just to write to a console.
When you create a windows app that has a WinMain entry point, there isn't an easy way to create a console. That said, if you want to go the other route (create a console app that spawns your window at some point), it isn't too difficult, but does require some work as far as setting up message loops and such. Basically, yes, you can have a window with a console. No, it isn't easy to set up.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Is there no way that I can just open a console and use cout/cin? No forms are open at this point. It seems like quite a complex process just to write to a console.
kialmur wrote:
Is there no way that I can just open a console and use cout/cin?
Sure, if you are creating a simple console application. However, since you have a GUI application, the rules change.
kialmur wrote:
seems like quite a complex process just to write to a console.
So just wrap it all up into a nice little class, and whenever you want something to be displayed in a console window, instantiate your class, and invoke a few methods. You could even skip the class part, and just put it all in a function (or three). Just call the functions whenever you want something to be displayed in a console window.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb