How can I get SetConsoleTextAttribute to work with my Console? I tried everything. First I redirected the cout and cin buffers so that my console can have input and output. But now it doesn't have Colour :S
I used:
HANDLE OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(OutputHandle, 10);
I don't think GetStdHandle is pointing to my console. Is there a way to redirect that? Or redirect all input/output to my console?
Currently I'm using this for redirecting and it works really well! Except for the colour part.
std::streambuf *CinBuffer, *CoutBuffer, *CerrBuffer; //Backup the older buffers.
std::fstream ConsoleInput, ConsoleOutput, ConsoleError; //My Buffers.
bool Debug::DebugConsole()
{
if(!ConsoleActive)
{
ConsoleActive = AllocConsole();
CinBuffer = std::cin.rdbuf();
CoutBuffer = std::cout.rdbuf();
CerrBuffer = std::cerr.rdbuf();
ConsoleInput.open("CONIN$", std::ios::in);
ConsoleOutput.open("CONOUT$", std::ios::out);
ConsoleError.open("CONOUT$", std::ios::out);
std::cin.rdbuf(ConsoleInput.rdbuf());
std::cout.rdbuf(ConsoleOutput.rdbuf());
std::cerr.rdbuf(ConsoleError.rdbuf());
}
return ConsoleActive;
}