About Taringa!
Functions like textcolor worked in old compilers like turbo C and Dev C.In today's compilers these functions would not work. I am going to give two function SetColor and ChangeConsoleToColors.You copy paste these functions code in your program and do the following steps.The code I am giving will not work in some compilers. Nov 29, 2016 Delphi is the ultimate IDE for creating cross-platform, natively compiled apps. Are you ready to design the best UIs of your life? Our award winning VCL framework for Windows and FireMonkey (FMX) visual framework for cross-platform UIs provide you with the foundation for intuitive, beautiful.
Popular channels
C/C if else if ladder with Examples setcolor function in C The header file graphics.h contains setcolor function which is used to set the current drawing color to the new color. I want to change the color of the text in c. I am using Turbo c 4.5 and Windows XP. I have used that textcolor(14) type code but it didn't work. It says: Call to undefined function 'textcolor' in function main I have included header files iostream.h, conio.h, windows.h, dos.h. Please suggest me.
Taringa!»Technology»Software»cout<<"Hola Mundo" ;
Buenas, primer post
Probablemente los usuarios avanzados ya lo sepan, pero muchos usuarios novatos de C++ preguntan como darle color a la consola (sin librerias graficas es una de las pocas cosas que se puede hacer para darle un toque mas user-friendly), para darle color a C++ hay dos formas:
system('color XX') ;
El cambio de color de la consola entera, siendo XX caracteres hexadecimales, cambia totalmente el color de la consola.
SetConsoleTextAttribute(GetStdHandle (STD_OUTPUT_HANDLE),X);
Con este comando se le puede cambiar el color de texto y de fondo a lo que se muestre despues de que la linea se ejecute, siendo X un numero entre 0 y 255.
Ahorabien, siendo los colores:
0 = Negro
1 = Azul
2 = Verde
3 = Aguamarina
4 = Rojo
5 = Purpura
6 = Amarillo
7 = Blanco
8 = Gris
9 = Azul claro
A = Verde claro
B = Aguamarina claro
C = Rojo claro
D = Purpura claro
E = Amarillo claro
F = Blanco brillante
como calcular X? Simple:
X=A*16+B;
A=color de fondo
B=color de texto
Nota: (De la A a la F los valores son de 10 a 15 respectivamente)
Asi, si queremos por ejemplo un texto azul claro sobre fondo amarillo:
X=6(fondo amarillo)*16+9(texto azul claro)= 105
y como es molesto recordar como se escribe SetConsoleTextAttribute(GetStdHandle (STD_OUTPUT_HANDLE),X) , pueden incluir en sus programas una rutina muy simple de mi creacion:
void color(int X)
{
SetConsoleTextAttribute(GetStdHandle (STD_OUTPUT_HANDLE),X);
}
y con solo escribir color(X) tendran el efecto deseado.
Saludos a todos, espero que les sirva!!
Hi all! my first post:-)Probablemente los usuarios avanzados ya lo sepan, pero muchos usuarios novatos de C++ preguntan como darle color a la consola (sin librerias graficas es una de las pocas cosas que se puede hacer para darle un toque mas user-friendly), para darle color a C++ hay dos formas:
system('color XX') ;
El cambio de color de la consola entera, siendo XX caracteres hexadecimales, cambia totalmente el color de la consola.
SetConsoleTextAttribute(GetStdHandle (STD_OUTPUT_HANDLE),X);
Con este comando se le puede cambiar el color de texto y de fondo a lo que se muestre despues de que la linea se ejecute, siendo X un numero entre 0 y 255.
Ahorabien, siendo los colores:
0 = Negro
1 = Azul
2 = Verde
3 = Aguamarina
4 = Rojo
5 = Purpura
6 = Amarillo
7 = Blanco
8 = Gris
9 = Azul claro
A = Verde claro
B = Aguamarina claro
C = Rojo claro
D = Purpura claro
E = Amarillo claro
F = Blanco brillante
como calcular X? Simple:
X=A*16+B;
A=color de fondo
B=color de texto
Nota: (De la A a la F los valores son de 10 a 15 respectivamente)
Asi, si queremos por ejemplo un texto azul claro sobre fondo amarillo:
X=6(fondo amarillo)*16+9(texto azul claro)= 105
y como es molesto recordar como se escribe SetConsoleTextAttribute(GetStdHandle (STD_OUTPUT_HANDLE),X) , pueden incluir en sus programas una rutina muy simple de mi creacion:
void color(int X)
{
SetConsoleTextAttribute(GetStdHandle (STD_OUTPUT_HANDLE),X);
}
y con solo escribir color(X) tendran el efecto deseado.
Saludos a todos, espero que les sirva!!
Well, I use borland compiler now, but if I need to use Dev-cpp to solve this problem, its fine with me.
I use cmd.exe on Windows XP Prof.
My problem is: I want to use the textattr() function of conio.h.. I maked a sample for you, but now I see that I cant get any colors too!
#include <stdio.h> #include <iostream> #include <conio.h> //this should be enough I guess using namespace std; string a; int main() { clrscr(); textcolor(2); gotoxy(3,3); textattr(4); cout << 'This should be underlined?'; cout << endl; cout << 'Wanna end this program? Press a key (Y) and then press enter..'; cin >> a; } |
But both, textcolor, and textattr doesnt work.. When I do textcolor([LIGHT]GREEN)
so, light and without light, it still doesnt work..
but functions, which can be found in conio.h, like clrscr() which clears the screen and gotoxy(3,3) which sets text on coords 3,3 works fine!!!
I think this is very strange..
Text Color In Dev C++
I just want to make a 'input'-field, this was a class I wanted to make..so it would look like: _______
and then if u enter on it something, the text self would be underlined too..
With such inputs I wanted to make a program, but it seems hard to just make text underlined:S
please, need some help! btw I am new to C++, but I know the basics..