Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

C++ setbkcolor() - Define the Background Color



In C++, the setbkcolor() is used to define Background Color of the screen. You can set any background color according to your need by using this function.

Syntax of setbkcolor() Function

The general syntax of this function is as follows:


setbkcolor(co);
Where:
co It represents color. It can be a "int" type value or variable. Its value is from 0 to 15 for VGA screen. It may also be a numerical constant identifier such as BLUE, RED and GREEN etc.


Example of setbkcolor() Function

The following C++ program displays the word "Welcome" in different colors and also with different background colors.


#include
#include
#include
using namespace std;
main()
{
int driver, mode, co;
driver = DETECT;
initgraph (&driver, &mode, " ");
cleardevice();
for (co = 0; c {
setbkcolor(co);
setbkcolor (co + 1);
settextstyle (0, 0, 2);
outtextxy (100, 10+co*20, "Welcome");
outtextxy(450, 400, "Press any key");
getch();
}
closegraph();
}


This post first appeared on Programming Explain, please read the originial post: here

Share the post

C++ setbkcolor() - Define the Background Color

×

Subscribe to Programming Explain

Get updates delivered right to your inbox!

Thank you for your subscription

×