论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > C语言程序设计教程
Tag:新手,函数,指针,数据类型,对象,Turbo,入门,运算符,数组,结构,二级,,tc,游戏,试题,问答,编译,视频教程

文本方式下菜单

文章类别:C语言程序设计 | 发表日期:2008-9-24 14:36:16

#include<process.h>
#include<stdlib.h>
#include<stdio.h>
#include<dos.h>
#include<conio.h>
#define down 80
#define up 72
#define esc 1
#define xy 77
#define xz 75
#define xx 80
#define xs 72
#define altf 33
#define altx 45
#define alte 18
#define altr 19
#define alto 24
#define alth 35
#define alts 31
#define altz 44
#define altm 50
#define enter 28
#define af10 68
int get_key()
 {
  union REGS rg;
  rg.h.ah=0;
  int86(0x16,&rg,&rg);
  return rg.h.ah;
 }
void box(int startx,int starty,int high,int width)
     {int i;
      gotoxy(startx,starty);
      putch(0xda);
      for(i=startx+1;i<width;i++) putch(0xc4);
      putch(0xbf);
      for(i=starty+1;i<high;i++)
       {
 gotoxy(startx,i);putch(0xb3);
 gotoxy(width,i);putch(0xb3);
 }
      gotoxy(startx+1,width);
       putch(0xc0);
       for(i=startx+1;i<width;i++) putch(0xc4);
       putch(0xd9);
       return;
}
main()
 {

  int i,key,x,y,l,lh,hzb,cx,jt,hqslh[8],f10,zcd=4,xsz,me;
  char *zh="File";
  char *lf[8];
  char *menu[]={"File","Edit","Run","Options","Help","Setup","Zoom","Menu"};
  char *red[]={"F","E","R","O","H","S","Z","M"};
  char *f[]={"loand file","save file ","print     ","modify    ","quit alt_x","dfd"};
  char *f1[]={"12345 file","save file ","print     ","modify    ","quit alt_x"};
  char *f2[]={"loand file","save file ","print     ","modify    ","quit alt_x"};
  char *f3[]={"loand file","save file ","print     ","modify    ","quit alt_x"};
  char *f4[]={"loand file","save file ","print     ","modify    ","quit alt_x"};
  char *f5[]={"loand file","save file ","print     ","modify    ","quit alt_x"};
  char *f6[]={"loand file","save file ","print     ","modify    ","quit alt_x"};
  char *f7[]={"loand file","save file ","print     ","modify    ","quit alt_x"};
  char buf[16*10*2],buf1[16*2];
  textbackground(1);
  clrscr();
  window(1,1,80,1);
  textbackground(15);
  textcolor(0);
  clrscr();
  window(1,1,80,2);
  for(i=0,l=0;i<8;i++)
   {
    x=wherex();
    y=wherey();
    cprintf("   %s",menu[i]);
    l=strlen(menu[i]);
    gotoxy(x,y);
    textcolor(RED);
    cprintf("   %s",red[i]);
    x=x+l+4;
    gotoxy(x,y);
    textcolor(BLACK);
   }
hqslh[0]=4;
for(i=0;i<8;i++)
  {
   zcd=zcd+strlen(menu[i])+4;
   hqslh[i+1]=zcd;
  }
while(1)
   {

    f10=0;
    key=0;
    hzb=0;
    lh=4;
   
    cx=0;
    while(bioskey(1)==0);
    key=get_key();
    while(key==af10)
       {
 while(!f10)
         {
          textbackground(0);
   textcolor(15);
   gotoxy(lh,1);
   cprintf("%s",menu[hzb]);
   key=get_key();
   if(key==altx) exit(1);
          if(key==xx) {f10=1;break;}
   if(key==esc||key==altf||key==alte||key==altr||key==alto||key==alth||key==alts||key==altz||key==altm){cx=1;}
   textbackground(15);
   textcolor(0);
   l=strlen(menu[hzb]);
          gotoxy(lh,1);
   cprintf("%s",menu[hzb]);
   gotoxy(lh,1);
   textcolor(RED);
   cprintf("%s",red[hzb]);
   if(cx) break;
   if(key==xy) {lh=lh==63?4:lh+strlen(menu[hzb])+4;hzb=hzb==7?0:hzb+1;}
   if(key==xz) {lh=lh==4?63:lh-strlen(menu[hzb-1])-4;hzb=hzb==0?7:hzb-1;}
         }
       }

  xsz=0;
  if(f10)
     {
      switch(hzb)
       {
 case 0: {for(i=0;i<=8;i++) lf[i]=f[i];lh=hqslh[0];xsz=1;me=0;break;}
 case 1: {for(i=0;i<=8;i++) lf[i]=f1[i];lh=hqslh[1];xsz=1;me=1;break;}
        case 2: {for(i=0;i<=8;i++) lf[i]=f1[i];lh=hqslh[2];xsz=1;me=2;break;}
        case 3: {for(i=0;i<=8;i++) lf[i]=f1[i];lh=hqslh[3];xsz=1;me=3;break;}
        case 4: {for(i=0;i<=8;i++) lf[i]=f1[i];lh=hqslh[4];xsz=1;me=4;break;}
        case 5: {for(i=0;i<=8;i++) lf[i]=f1[i];lh=hqslh[5];xsz=1;me=5;break;}
        case 6: {for(i=0;i<=8;i++) lf[i]=f1[i];lh=hqslh[6];xsz=1;me=6;break;}
        case 7: {for(i=0;i<=8;i++) lf[i]=f1[i];lh=hqslh[7];xsz=1;me=7;break;}
      
       }
      }
   else
      {
        switch(key)
       {
 case 33: {for(i=0;i<=8;i++) lf[i]=f[i];lh=hqslh[0];xsz=1;me=0;break;}
 case 18: {for(i=0;i<=8;i++) lf[i]=f1[i];lh=hqslh[1];xsz=1;me=1;break;}
        case 19: {for(i=0;i<=8;i++) lf[i]=f2[i];lh=hqslh[2];xsz=1;me=2;break;}
        case 24: {for(i=0;i<=8;i++) lf[i]=f3[i];lh=hqslh[3];xsz=1;me=3;break;}
        case 35: {for(i=0;i<=8;i++) lf[i]=f4[i];lh=hqslh[4];xsz=1;me=4;break;}
        case 31: {for(i=0;i<=8;i++) lf[i]=f5[i];lh=hqslh[5];xsz=1;me=5;break;}
        case 44: {for(i=0;i<=8;i++) lf[i]=f6[i];lh=hqslh[6];xsz=1;me=6;break;}
        case 50: {for(i=0;i<=8;i++) lf[i]=f7[i];lh=hqslh[7];xsz=1;me=7;break;}
       }
      }

    if(key==altx) exit(1);
    if(xsz)
      {
       textbackground(0);
       textcolor(15);
       gotoxy(lh,1);
       if(me==0) {menu[0]=zh;}
       cprintf("%s",menu[me]);
       gettext(lh,2,lh+15,8,buf);
       window(lh,2,lh+15,8);
       textbackground(15);
       textcolor(0);
       clrscr();
       window(lh,2,lh+15,9);
       box(1,1,7,16);
       for(i=2;i<7;i++)
 {
  gotoxy(2,i);
  cprintf("%s",lf[i-2]);
 }
      gettext(lh,2,lh+16,3,buf1);
      textbackground(0);
      textcolor(15);
      gotoxy(2,2);
      cprintf("%s",lf[0]);
      y=2;
      key=get_key();
      while(key!=altx&&key!=enter&&key!=esc)
       {
 if(key==up||key==down)
   {
    puttext(lh,y,lh+16,y+1,buf1);
    if(key==up) y=y==2?6:y-1;
    if(key==down) y=y==6?2:y+1;
    gettext(lh,y,lh+16,y+1,buf1);
    textcolor(15);
    textbackground(0);
    gotoxy(2,y);
    cprintf("%s",lf[y-2]);
   }
        key=get_key();
 }
 if(key==altx) exit(0);
 if(key==enter) {printf("hello welcom ");exit(1);}
 else
  {
   puttext(lh,2,lh+15,8,buf);
   textbackground(15);
   textcolor(0);
   window(1,1,80,2);
          gotoxy(lh,1);
   cprintf("%s",menu[me]);
          gotoxy(lh,1);
          textcolor(RED);
          cprintf("%s",red[me]);
          menu[0]=zh;
  }
      }
  }
}

上一篇:{技巧}TC中的串口编程 人气:7454
下一篇:{技巧}XP环境下的tc鼠标调用 人气:6892
视频教程列表
文章教程搜索
 
C语言程序设计推荐教程
C语言程序设计热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058