How to Change Text Color In Code Block by Making Setcolor Function ?


how to use setcolor function in code block
how to change text color in code block

Hello Friends my name is Harvinder Singh today I am talking about on how to use setcolor(); function in code: block do not west time & let's get's start.


Use Setcolor function in Code-block Step by Step



  • Firstly open Code : Block
  • After Opening Code : Block create new projetc or open old project and Include windows.h & stdio.h header file.
  • Copy the code below and Past this code after including stdio.h & windows.h header file.
  • Code of setcolor(); Function

    void 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); // SetConsoleTextAttributes(hStdOut,wColor); SetConsoleTextAttribute(hStdOut,wColor); } }
  • After pasting this code create main function and use setcolor function with many colors code.

Explanation : In Graphics, each color is assigned a number. Total number of colors available are 16. For example, setcolor(RED) or setcolor(4) changes the current drawing color to RED. Remember that default drawing color is WHITE. The Colors table is given below.

Color Code

COLOR INT VALUES ------------------------------- BLACK 0 BLUE 1 GREEN 2 CYAN 3 RED 4 MAGENTA 5 BROWN 6 LIGHTGRAY 7 DARKGRAY 8 LIGHTBLUE 9 LIGHTGREEN 10 LIGHTCYAN 11 LIGHTRED 12 LIGHTMAGENTA 13 YELLOW 14 WHITE 15
Syntax :
void setcolor(int color);

Below is the implementation of setcolor( ) function.


Example

#include #include void 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); // SetConsoleTextAttributes(hStdOut,wColor); SetConsoleTextAttribute(hStdOut,wColor); } } void main() { setcolor(9); printf("Brightgoal"); setcolor(12); printf("Brightgoal"); getch(); }

Enjoy Now.

3 Comments

  1. https://www.mediafire.com/download/769mtbw4u59eio3

    ReplyDelete
  2. https://www.mediafire.com/download/9i3hk0djn3qjkh0

    ReplyDelete
  3. Best Casino Apps in Pennsylvania - DrMCD
    Best Casino Apps in Pennsylvania. 김천 출장샵 Use our Ranking & Store ranking to see the top apps for PA casino apps. We also rank 통영 출장마사지 mobile 충주 출장마사지 and tablet 강원도 출장마사지 apps on our 이천 출장안마

    ReplyDelete

Newest