Console Debug Window
By Alan Baylis 07/04/04
Download the Console Debug Window demo with Source Code
One aspect to programming a Win32 app that we programmers lack is the ability to
simply output the value of a variable at runtime for debugging purposes. A
workaround to this has commonly been to use a message box to display the value,
but this is far less practical than using stdio and iostreams. Now you can add
all the convenience of a console window to your Win32 project by adding the file
console.cpp from the demo to your project with its header file and create an
object of type ConsoleWindow.
If your ConsoleWindow object is called Console as it is in the demo, you open
the console window by calling Console.Open() and close it with Console.Close().
If you try to use the console window when it is closed then this may
upset further input/output so I recommend that you also make a call to Console.Status()
to check that the console window is open before using it. It simply returns true if it is open
and false if closed.
The method I use is a blend of the methods used by Mark Nelson in his program
called ConStream and the article 'Adding Console
I/O to a Win32 GUI App' in the Windows Developers
Journal, December 1997. I hope you find the ConsoleWindow class as useful as I
do.
Copyright © 1998 - 2010 Alan Baylis, All Rights Reserved