Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript Site
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

US Job listings




   Misc

   Amazon

   Links

    


Coloured text example
 

 

 

Description

This changes the color of the text / background of the text in a console window . Experiment with different numbers for setcolor(). Useful for menus .

Code

#include <stdio.h>
#include <windows.h>
#include <conio.h>


void setcolor(unsigned short color)
{
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hcon,color);
}

int main()
{
setcolor(1);
printf("thisll be blue\n");
setcolor(2);
printf("how about some green\n");
setcolor(5);
printf("and another color\n");

getch();


return 0;
}

Information

Tested on Visual C++

 

 

 

 

Download

setcolour.txt


 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
Browser Detection(PHP)
Get the names of all processes on your machine(C Sharp)
aligning text(CSS)
display html source with line numbers(php)
Display the Open With dialog(VB)
Launch Add New Hardware wizard(VB)
Ping with VB(VB)
Getting the length of a string(PHP)

    




Copyright © 2003 by programmershelp.co.uk