development/Common/Utility/source/MainConsole.cpp
//This will set the forground color for printing in a console window.
This will set the forground color for printing in a console window.
This will set the forground color for printing in a console window .
void MainConsole::SetColor(int ForgC)
{
    WORD wColor;
    HANDLE hStdOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    if(::GetConsoleScreenBufferInfo(hStdOut, &csbi))
    {
        wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
        ::SetConsoleTextAttribute(hStdOut, wColor);
    }
    return;
}
void MainConsole :: SetColor ( int ForgC ) { WORD wColor ; HANDLE hStdOut = :: GetStdHandle ( STD_OUTPUT_HANDLE ) ; CONSOLE_SCREEN_BUFFER_INFO csbi ; if ( :: GetConsoleScreenBufferInfo ( hStdOut , & csbi ) ) { wColor = ( csbi . wAttributes & 0xF0 ) + ( ForgC & 0x0F ) ; :: SetConsoleTextAttribute ( hStdOut , wColor ) ; } return ; }
This will set the forground color for printing in a console window.
This will set the forground color for printing in a console window .
//We will need this handle to get the current background attribute //We use csbi for the wAttributes word. //Mask out all but the background attribute, and add in the forgournd color