I was just wondering if anyone knew how to run two linked output windows at the same time or if it is even possible. I'd appreciate any and all help. Thanks!!! ^_^

Dani AI

Generated

Practical, maintainable options for giving a text-RPG a second “window” (the scenario described by @#include<DAN.h>). These approaches avoid relying on console-host behavior and cover simple GUI integration, a multi-process IPC route for real consoles, and terminal/terminal-emulation libraries. This expands on the thread responses from with concrete steps and references.

One clean solution is to keep the game logic as an engine (no UI code) and build a small GUI front end with two text widgets: one for the main I/O and another for stats. That keeps everything in one process and makes updating the stats instantaneous. Tooling examples: Qt (QTextEdit) and wxWidgets (wxTextCtrl). Pattern (pseudocode):

// on input submit
cmd = inputWidget->text();
engine.processInput(cmd);
outputWidget->append(engine.popOutput());
statsWidget->setText(engine.getStatsString());

If you really want two real console windows, use separate processes and link them with IPC (anonymous pipes, named pipes, or sockets). Typical steps: create pipes or a named pipe server, spawn child processes (you can pass a mode flag so both run the same binary in different roles), redirect their stdio or open a pipe connection, then relay messages. This gives each child its own console but adds synchronization and I/O threading complexity. See Microsoft docs for process creation and named pipes: and Named Pipes.

If you prefer staying in one console window but want pane-like behavior, consider a terminal/UI library such as PDCurses, or on modern Windows use the pseudo-console (ConPTY) family of APIs (see Windows Console docs). PDCurses works on older systems; ConPTY requires newer Windows.

Quick tips: keep engine and UI decoupled; never block the UI thread (use async or worker threads); if spawning consoles on Windows, spawn with appropriate flags (for example CREATE_NEW_CONSOLE) and test on the target OS. References: QTextEdit, wxTextCtrl, PDCurses, Windows Console.

Recommended Answers

All 4 Replies

What do you mean by "output window"?

If you mean some TTY (like the console) then the answer is: yes, it is possible.
If you mean some other thing then the answer is: maybe.

Either way, you're going to have to be dinking around with things in an OS-specific way.

A better question is why on earth you want to duplicate your output to multiple <something>s?

(BTW. If you are using Unix or Linux, type "man tee".)

I'm using Dev-C++ and my OS is Windows Vista. The output for my programs comes up in a single Cprompt window. What I would like to know is if there is any way to have two or more Cprompt windows to be displayed and linked with eachother.

This is basically what I mean:

Window One: (prompts for age)
(user inputs a number and hits enter)
Window Two: (displays "Your age is" what ever the user types into Window One)

This is probably really confusing to you, because its confusing to me as well. Basically I would like to know if there is any way that I can run one program that creates to Cprompt windows that will run simultaniously and be able to share data with eachother. Any help or advice would be VERY useful.

You've explained yourself very clearly.

In Windows, an application is only permitted to have one "console" attached at any given time. There are tricky ways around this, but those ways involve far more than you are ready to handle... besides which, it is a weird thing you want to do. (Though, admittedly, cool.)

You could "fake it" by having your application put up a Windows multi-line edit control for the output window. You can change the font and colors to match the console. This is as close to the same thing as you can easily get.

Do you have Win32 documentation? (You'll need it for this!)


Keep in mind that console processes aren't supposed to be aware of "windows" and "console windows" and the like. They are only supposed to understand input and output streams. How the streams are associated with the program is supposed to be entirely up to the person using the program. What I am saying is that you are trying to write a Windows application that just happens to use the Windows Console.

Hope this makes sense, and helps.

Thanks, and it mostly does make sense to me, but I've only been programming for a year and a half so it's not all completely clear. The actual application I was hoping to use to console windows for was so that when you were playing a text RPG that I made you would also be able to see your stats, weapons, time, etc. But I guess I'm going to have to find a way around using two windows. Thanks for all your help!!! ^_^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.