Tuesday, November 19
Easy Colouring
As promissed here is bit easy technique for those colour commands;
Hope you guys understand it :
Theme here is to use funcitons to determin command stuff i.e. how much easy would it be if you only have to type
color(r); //red colour
here is the function that will help you to use colours easily
______________________________________________________________________
- HANDLE Output=GetStdHandle(STD_OUTPUT_HANDLE);
- void colour(int x)
- {SetTextAttribute(Output,x);}
______________________________________________________________________
here if you remember colour codes integers just use them as follows:
colour(10); //green
and if you want to make it runing upon character values you can place switch in it
- HANDLE Output=GetStdHandle(STD_OUTPUT_HANDLE);
- void colour(char ch)
- {
- int x;
- switch (ch)
- {
- case 'r': x=12; break; //red
- case 'b': x=9; break; //blue
- case 'g': x=10; break; //green
- case 'a': x=11; break; //aqua
- case 'v': x=13; break; //voilet
- case 'y': x=14; break; //yellow
- case 'w: x=15; break; //white
- }
- SetTextAttribute(Output,x);
- }
now you can call it as this;
colour('r'); //red colour
end of post;
Dont U Think It is SetConsoleTextAttribute ,,,,,,,
ReplyDelete2 stars already for this post and no explanation needed in comments :)
ReplyDeletethese are two 5 stars from community ++ :)
ReplyDelete