Program : NAVIGATIONAL MENU
Platform : Turbo C 3.0Description : It is a program to demonstrate the menu system in C/C++. It also uses navigation through ARROW keys..........!!
View or Download CPP
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
int ch=1;
void menu();
void choice();
int main()
{
menu();
getch();
return 0;
}
////////////////////////////////
////////////////////////////////
void menu()
{
int gdriver = DETECT, gmode,i;
/* initialize graphics mode */
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
setcolor(2);
for(i=0;i<10;i++){rectangle(10+i,10+i,620+i,460+i);delay(50);}
setfillstyle(1,15);
bar(40,40,600,440);
settextstyle(7,0,5);
outtextxy(270,60,"MENU");
setcolor(4);
settextstyle(1,0,2);
/* 1 */
rectangle(180,145,450,180);
rectangle(185,147,445,178);
/* 2 */
rectangle(180,195,450,230);
rectangle(185,197,445,228);
/* 3 */
rectangle(180,245,450,280);
rectangle(185,247,445,278);
/* 4 */
rectangle(180,295,450,330);
rectangle(185,297,445,328);
/* 5 */
rectangle(180,345,450,380);
rectangle(185,347,445,378);
setcolor(1);
outtextxy(230,150,"1.EDUCATION");
outtextxy(230,200,"2.SPORTS");
outtextxy(230,250,"3.ENTERTAINMENT");
outtextxy(230,300,"4.POLITICS");
outtextxy(230,350,"5.EXIT");
setcolor(9);
rectangle(180,145,450,180);
rectangle(185,147,445,178);
choice();
}
//////////////////////////////////
//////////////////////////////////
void choice()
{
switch(getch())
{ case 'H':
switch(ch)
{
case 2:setcolor(4);
rectangle(180,195,450,230);
rectangle(185,197,445,228);
setcolor(9);
rectangle(180,145,450,180);
rectangle(185,147,445,178);
ch--;
choice();
case 3:setcolor(4);
rectangle(180,245,450,280);
rectangle(185,247,445,278);
setcolor(9);
rectangle(180,195,450,230);
rectangle(185,197,445,228);
ch--;
choice();
case 4:setcolor(4);
rectangle(180,295,450,330);
rectangle(185,297,445,328);
setcolor(9);
rectangle(180,245,450,280);
rectangle(185,247,445,278);
ch--;
choice();
case 5:setcolor(4);
rectangle(180,345,450,380);
rectangle(185,347,445,378);
setcolor(9);
rectangle(180,295,450,330);
rectangle(185,297,445,328);
ch--;
choice();
default : choice();
}
break;
case 'P':/*if(ch<5&&ch>=1){ch++;*/
switch(ch)
{
case 1:setcolor(4);
rectangle(180,145,450,180);
rectangle(185,147,445,178);
setcolor(9);
rectangle(180,195,450,230);
rectangle(185,197,445,228);
ch++;
choice();
case 2:setcolor(4);
rectangle(180,195,450,230);
rectangle(185,197,445,228);
setcolor(9);
rectangle(180,245,450,280);
rectangle(185,247,445,278);
ch++;
choice();
case 3:setcolor(4);
rectangle(180,245,450,280);
rectangle(185,247,445,278);
setcolor(9);
rectangle(180,295,450,330);
rectangle(185,297,445,328);
ch++;
choice();
case 4:setcolor(4);
rectangle(180,295,450,330);
rectangle(185,297,445,328);
setcolor(9);
rectangle(180,345,450,380);
rectangle(185,347,445,378);
ch++;
choice();
default : choice();
}
/*}*/break;
case 27: exit(0);
case 13: switch(ch){
case 1:setcolor(MAGENTA);outtextxy(230,150,"1.EDUCATION");
setcolor(3);outtextxy(200,400,"You selected EDUCATION");getch();exit(0);
case 2:setcolor(MAGENTA);outtextxy(230,200,"2.SPORTS");
setcolor(3);outtextxy(200,400,"You selected SPORTS");getch();exit(0);
case 3:setcolor(MAGENTA);outtextxy(230,250,"3.ENTERTAINMENT");
setcolor(3);outtextxy(200,400,"You selected ENTERTAINMENT");getch();exit(0);
case 4:setcolor(MAGENTA);outtextxy(230,300,"4.POLITICS");
setcolor(3);outtextxy(200,400,"You selected POLITICS");getch();exit(0);
case 5:exit(0);
default : choice;
}
default : choice();
}
}
/* Codetechie.blogspot.com */
0 comments:
Post a Comment