You are here

Console window for GUI-based Windows applications

I use this window for diagnostic issues in release versions. Visual C ++, unfortunately, doesn't initialize cin, court and cerr properly in non-text based application, ie one can in a gui based application not stream in a console window.

The solution to this problem is, of course, to design a separate output stream, that is linked to a console window. The implementation is so simple that it almost invites you to your own experiments.

To implement a stream sounds initially very complicated. But it is much easier than you think, since the design of the stream base classes has been designed for extension. This was made possible by splitting the implementation of a stream in two classes. An outer class (basic_istream, basic_ostream) provides the interface to the inner class (basic_streambuf), which make up the actual input/output accomplished in the device. At the same time the outer class takes care of the formatting of the output. All output streams are derived from basic_ostream. It follows that for the development of a new stream only the inner class must be changed. The outer class remains the same (of course it must use the new inner class). Enough of the preface: