Friday 5 September 2014

Console Colour Changing in C++

Structure of the Problem Requirements 

In this problem we will learn about the colour changing in Console in C++ Program. For changing colour of text or background we include the windows.h class in C++ program. Windows library deal with such a events. In our program we make an instance of handle class and then use it to change the colour of the required lines. Here is the source code of this problem which help you in better understanding.

Source Code



#include<iostream>
#include<windows.h>
using namespace std;
int main ()
{
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute(h,FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<"\t \t \t \t LEP \n \n \n ";
SetConsoleTextAttribute(h,FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<" CEO & Founders  :" <<" Asad Niazi & Naeem Sajid \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<"  Developers      :" <<" Niazi,Sajid,Anoshka Sharma,Rani,Zarlish,John Peter \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<"  Website         :" <<" WWW.ANCODINGPOINT.COM \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<"  Facebook Address:" <<" https://www.facebook.com/riphahiui \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<"  Twitter Address :" <<" https://twitter.com/LetsEnjoyProgra  \n " <<endl;
}

Output of the Program

Change Colour in Console
Change Colours in Console 

Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

2 comments: Post Yours! Read Comment Policy!▼
Important Note:
We have Zero Tolerance to Spam. Chessy Comments and Comments with Links will be deleted immediately upon our review.

  1. indeed it will bring lot of attraction in my project . thumb up for you man :)

    ReplyDelete
  2. Bring new colors in your life :)

    ReplyDelete