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…

 

How to check for keyhit in a windows console application?

For this purpose we use _kbhit function included in conio.h file. Please note that conio.h is a non-standard header file so can’t say if _kbhit will be available in other libraries. The purpose of  _kbhit is to check whether a key has been hit and so then we can use this function to wait till […]
Continue reading…

 

Progress messages or progress bars in a console application, Win2000 and Linux style

Ever seen that white progress bar in Windows 2000 while it loads and that spinning stick while Linux is being installed. Out of my curiosity I wrote some functions which emulates these progress bars. You can optimize/customize these functions for your needs, a thank you message will do the trick with me! Take a look […]
Continue reading…