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
Find all links(PHP)
shared resources on your pc(VB)
Open a file for writing to(VB)
AOL supported(ASP.net)
Creating a table in a MySQL database(PHP)
Display all files on the C drive(Powershell)
Delete a folder(ASP)
GetSerialNumber Procedure(VB)

    




Copyright © 2003 by programmershelp.co.uk