0

I googled about this topic and the previous questions were about how to add a Form into a Console Application. But, I am looking for something different. My question is:
How do I add a console into my existing Windows form app?
I am building a "text only" game and I want it to have a nice interface. I tried to add a form into a console app, but, I want the form to control the console. I also tried to hide the console when its launching the form, but, it seems impossible. Maybe there is a way to put the Form in charge of the console.

Edit based on comments below:
This question differs from previous questions because I want the form to launch and control the console. I don't want the ** console** to launch the form. Currently there is no possible way I am aware of to either hide the console or to transport info from the form to the console to control it.

phoenix
  • 3,069
  • 3
  • 22
  • 29
Captain JJ
  • 89
  • 1
  • 1
  • 10
  • 1
    Duplicate of: http://stackoverflow.com/q/4362111/4620101 – Szabolcs Dézsi Jan 30 '16 at 08:25
  • @SzabolcsDézsi no. because there is no possible way to hide the console, or to transport info from the form to the console, i want the form to lunch and control the console. I dont want the ** console** to lunch the form. – Captain JJ Jan 30 '16 at 08:44
  • Uhh, that's exactly what the top answer to that other question says. You create a Windows Forms application (not a console one), and then p/invoke and call the `AllocConsole` function. Bingo-bango, instant console window in your WinForms app. You will of course have trouble if you try to do anything fancy, Windows doesn't really support hybrid console-Windows applications. But `AllocConsole` is your best and most straightforward bet for faking it. – Cody Gray - on strike Jan 30 '16 at 14:45
  • The technical details from a Win32 perspective are here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682528.aspx. This may go over your head if you only know WinForms and little else about Windows programming. But the key is: *"Typically, a process uses AllocConsole to create a console when an error occurs requiring interaction with the user. For example, a GUI process can create a console when an error occurs that prevents it from using its normal graphical interface, or a console process that does not normally interact with the user can create a console to display an error."* – Cody Gray - on strike Jan 30 '16 at 14:48

0 Answers0