My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

program of main menu

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
int color;
void arrow(int xx,int yy,int color)
{   setcolor(color);
    int a[]={xx-50,yy+7,xx-40,yy+7,xx-20,yy+20,xx-40,yy+33,xx-50,yy+33,xx-50,yy+26,xx-40,yy+26,xx-27,yy+20,xx-40,yy+14,xx-50,yy+14,xx-50,yy+7};
    drawpoly(11,a);
    setfillstyle(1,color);
    floodfill(xx-40,yy+10,color);
}

void setfocus(int l,int r,int t,int b,char s[])
{    arrow(l,t,8);
     setcolor(15);
     rectangle(l,t,r,b);
     setfillstyle(1,15);
     floodfill(l+2,t+2,15);
     setcolor(6);
     outtextxy(l+5,t,s);
}

void lostfocus(int l,int r,int t,int b,char s[])
{    arrow(l,t,7);
     setcolor(7);
     rectangle(l,t,r,b);
     setfillstyle(1,7);
     floodfill(l+2,t+2,7);
     setcolor(6);
     outtextxy(l+5,t,s);
}

void menu(char x[][50],int msize,int hl)
{
     int lf,tp,rh,bt;
     lf=225;
     rh=lf+130;
     tp=150;
     bt=tp+40;
     setcolor(5);
     settextstyle(1,HORIZ_DIR,5);
     outtextxy(200,60,x[0]);

     settextstyle(1,HORIZ_DIR,4);
     for(int i=1;i<=msize;i++)
     {   if(i==hl)
     setfocus(lf,rh,tp,bt,x[i]);
     else
     lostfocus(lf,rh,tp,bt,x[i]);
     tp+=40;
     bt+=40;
     }
}

void getkey(int &j,int &k,int &l)
{    REGS n,m;
     m.h.ah=0X00;
     int86(22,&m,&n);
     j=n.h.ah;
     k=n.h.al;
     m.h.ah=0X02;
     int86(22,&m,&n);
     l=n.h.al;
}

void main()
{         int d,m,e;
      d=DETECT;
      initgraph(&d,&m,"c:/tc");
      e=graphresult();

if(e!=0)
{
     cout<<"Graphics not inialised";
     getch();
     return;
}
settextstyle(1,HORIZ_DIR,4);
setbkcolor(7);
int ac,sc,st,z=1,t=1;
char mstr[][50]={"MAIN MENU","MENU 1","MENU 2","MENU 3","MENU 4","MENU 5"};
char menu1[][50]={"SUB MENU 1","TITLE 1","TITLE 2","TITLE 3","TITLE 4","BACK"};
char menu2[][50]={"SUB MENU 2","TITLE 1","TITLE 2","TITLE 3","TITLE 4","BACK"};
char menu3[][50]={"SUB MENU 3","TITLE 1","TITLE 2","TITLE 3","TITLE 4","BACK"};
char menu4[][50]={"SUB MENU 4","TITLE 1","TITLE 2","TITLE 3","TITLE 4","BACK"};
char menu5[][50]={"SUB MENU 5","TITLE 1","TITLE 2","TITLE 3","TITLE 4","BACK"};
while(1)
{       label:
    menu(mstr,5,z);
    getkey(sc,ac,st);
       /*sound(7);
    delay(100);
    nosound();   */
    if(sc==72 && z>=1)
    {
          if(z==1)
          {    z=5;
           continue;
          }
          z--;
    }
    else if(sc==80&& z<=5)
    {
          z++;
          if(z==6)
          z=1;
    }
    else if(sc==1)
    break;
    else if(sc==28)
    {  cleardevice();
       while(1)
       {
          if(z==1)
          menu(menu1,5,t);
          if(z==2)
          menu(menu2,5,t);
          if(z==3)
          menu(menu3,5,t);
          if(z==4)
          menu(menu4,5,t);
          if(z==5)
          menu(menu5,5,t);


              getkey(sc,ac,st);

              if(sc==72 && t>=1)
              {
              if(t==1)
              {    t=5;
                   continue;
              }
               t--;
              }
              else if(sc==80&& t<=5)
              {
               t++;
               if(t==6)
               t=1;
              }

              else if(sc==28)
              {    if(t==5)
               {  cleardevice();
                  goto label;
               }
               else
               return;
              }
       }
    }
}
getch();
closegraph();
}

0 comments: