Skip to main content
gamedev.net
🔒 Locked

Creating a debug console

Started by vNistelrooy Aug 5, 2005 at 12:21 PM 2 replies 1.2k views
Original Post
vNistelrooy
vNistelrooy
Ok, what hell is wrong here? I'm calling ::AllocConsole(), which doesn't report an error, then I'm calling ::SetConsoleTitle("title") which returns non-zero as well, and finally I'm calling ::GetStdHandle(STD_OUTPUT_HANDLE) which returns a valid handle (!=INVALID_HANDLE_VALUE). Why then printing to console or calling ::SetConsoleScreenBufferSize() fail with error ERROR_INVALID_HANDLE??
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
DrEvil
DrEvil
Not sure about your specific question, but I use this to create a console and use std::cout and such for printing to it.

#ifdef _DEBUG
if (AllocConsole())
{
freopen ("CONIN$", "rb", stdin);
freopen ("CONOUT$", "wb", stdout);
freopen ("CONOUT$", "wb", stderr);
}
#endif
vNistelrooy
vNistelrooy
Alright solved. Just using ::CreateConsoleScreenBuffer and friends.
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
njpaul
njpaul
Quote:
Original post by DrEvil
Not sure about your specific question, but I use this to create a console and use std::cout and such for printing to it.

#ifdef _DEBUG
if (AllocConsole())
{
freopen ("CONIN$", "rb", stdin);
freopen ("CONOUT$", "wb", stdout);
freopen ("CONOUT$", "wb", stderr);
}
#endif


Worked like a charm for me. Ratings++.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.