19

Is it possible to create two console windows (one being the main) and the secondary being a pop-up like a message box in Windows Forms?

I only want the secondary console window to hold IDs (that will be hard coded into the application) So the user does not have to keep returning to the main menu to check available IDs

If so how would you go about it?

Many Thanks

Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
Tom C
  • 804
  • 2
  • 11
  • 24

3 Answers3

24

Yes, you can do it.

The solution is actually very simple - our process can start a new helper child-process, so the helper process will display whatever our process sends it. We can easily implement such a solution with pipes: for each new console (that I'll call logger), we'll open a pipe, and execute a Console-Helper application - the role of this application is very simple, it will print everything sent through the pipe. Check out this article Multiple consoles for a single application for details (contains the source code).

In the code, it implement a console class CConsoleLogger, then you can create multiple console windows like:

CConsoleLogger another_console;
another_console.Create("This is the first console");
another_console.printf("WOW !!! COOLL !!! another console ???");

And you will get something like:

enter image description here

herohuyongtao
  • 49,413
  • 29
  • 133
  • 174
  • 22
    You should summarize the basic steps involved, so that this answer is self-contained. Link-only answers should be avoided on SO. – IInspectable Dec 30 '13 at 21:15
4

Take a look at http://msdn.microsoft.com/en-us/library/windows/desktop/ms682528(v=vs.85).aspx for instructions for creating a console window.

Jon Trauntvein
  • 4,453
  • 6
  • 39
  • 69
-3

Nop

A process can be associated with only one console.

AllocConsole

Alex Rubel
  • 11
  • 1