How to change console application text color?

Easy! call SetConsoleTextAttribute function with appropriate color codes as follows… [sourcecode language=’cpp’]// A generic function call to set color for text being output void SetColor( const int Color ) { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), Color ); } int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { // Only change foreground color SetColor( FOREGROUND_BLUE ); cout
Continue reading…

 

Changing background color of a console application?

Changing background color of a console application can be accomplished in two ways… Through console application API’s provided by Microsoft. Through color command in windows. The second one is the easiest, let me show you how to do so… [sourcecode language=”cpp”]// This will change the background to crimson and foreground color to white const int […]
Continue reading…

 

gotoxy in a console application in windows

gotoxy! what’s that? gotoxy was one of my favorite functions in turbo c++, it moves the input cursor in a console application/MS-DOS application from one location to another. So is there an equivalent function in a windows console application which does the same? Yes, it’s called SetConsoleCursorPosition. Sample code As always with me here is […]
Continue reading…

 

Change console application title!

It’s easy to change the title of a console application, just call SetConsoleTitle with the new title. Eg: [sourcecode language=’cpp’]int main( int argc, char** argv) {      SetConsoleTitle(“Nibu’s console”); return 0; }[/sourcecode] Well now the title changes, but you can see the old title for a moment before it changes to the new one (well […]
Continue reading…