Click to See Complete Forum and Search --> : how to open console window for debug prints
umen
May 19th, 2008, 05:29 AM
hello all
i have win32 gui application but when i debug it i need to do debug prints
i was thinking about opening console window and print the debug strings
but how can I open such console ?
sunil_cguru
May 19th, 2008, 05:56 AM
You can use OutputDebugString to print debug statements to your VC++ IDE output window. If you still want to create a console window you can use CreateConsoleScreenBuffer.
Codeplug
May 19th, 2008, 08:34 AM
>> If you still want to create a console window you can use CreateConsoleScreenBuffer
This will not create a console window in GUI app. You can use AllocConsole() to create a console window - but your stdout and stdin descriptors will not be "hooked up" to it - so printf and cout will not work. You can use ReadConsole() and WriteConsole() - or you can "hook up" the CRT to the console to make normal CRT I/O work as expected.
This is an older article on hooking up the CRT to a console, however, it's for the old CRT, not the 8.0 CRT that ships with VS 2005 and up. Although it may still work for the 8.0 CRT.
http://www.halcyon.com/~ast/dload/guicon.htm
gg
brahmma
May 22nd, 2008, 06:53 AM
You don't necessarily need a console window to print your debugging information. As already pointed out by another user, you can use OutputDebugString() to print information.
You can use an application like DebugView to view the information printed out (if not the IDE), since it has several advantages over the IDE in what it does.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.