您现在的位置:计算机技术学习网 > 技术中心 > 编程开发 > C >

c语言课程设计_文本模式下的菜单演示

来源:不详 责任编辑:栏目编辑 发表时间:2013-07-01 19:44 点击:
/****************************************/ /* TurboC2.0 运行通过 */ /* 文本模式下的菜单演示 */ /****************************************/ #include<process.h> #include<stdlib.h> #include<dos.h> #include<conio.h> /*define keys scan code*/ #define Key_DOWN 80 #define Key_UP 72 #define Key_A 30 #define Key_B 48 #define Key_C 46 #define Key_E 18 #define Key_ENTER 28 int key(); main() { int ky,y; char ch; textbackground(0); clrscr(); do { textmode(C80); /*set display mode*/ textbackground(13); /*draw menu window*/ textcolor(RED); window(7,8,19,15);/*open window*/ clrscr(); textbackground(1); textcolor(LIGHTRED); window(8,9,18,14); clrscr(); gotoxy(3,3);cprintf("E:exit\r\n"); /*display menu items*/ gotoxy(3,4);cprintf("A:dir\r\n"); gotoxy(3,5);cprintf("B:dir/p\r\n"); gotoxy(3,6);cprintf("C:dir/w\r\n"); y=10; upbar(y-1);/*draw light bar*/ do { ky=key(); switch(ky) { case Key_A: y=12-1,ky=Key_ENTER; break; case Key_B: y=13-1,ky=Key_ENTER; case Key_C: y=14-1,ky=Key_ENTER; break; case Key_E: y=11-1,ky=Key_ENTER; break; case Key_DOWN: if(y<13) { upbar(y); y++; } break; case Key_UP: if(y>10) { downbar(y); y--; } break; } }while(ky!=Key_ENTER); textcolor(WHITE); switch(y+1) { case 11: ch='%';break; case 12: system("cls"); system("dir"); getch(); break; case 13: system("cls"); system("dir/p"); getch(); break; case 14: system("cls"); system("dir/w"); getch(); break; } if(ch=='%') break; clrscr(); }while(1); clrscr(); } /*read char on key,return 16 bit scan code*/ int key() { int k; while(bioskey(1)); k=bioskey(0); k=k&0xff00; k=k>>8; return k; } /*int key() {union REGS rg; rg.h.ah=0; int86(0x16,&rg,&rg); return rg.h.ah; }*/ /*red bar down*/ upbar(int y) { int i; typedef struct texel_struct { unsigned char ch; unsigned char attr; }textl; textl t; for(i=9;i<=17;i++) { gettext(i,y,i,y,&t); t.attr=0x1C; puttext(i,y,i,y,&t); gettext(i,y+1,i,y+1,&t); t.attr=0x4f; puttext(i,y+1,i,y+1,&t); } gotoxy(3,y+1); return; } /*red bar up*/ downbar(int y) { int i; typedef struct texel_struct { unsigned char ch; unsigned char attr; }texel; texel t; for(i=9;i<=17;i++) { gettext(i,y,i,y,&t); t.attr=0x1C; puttext(i,y,i,y,&t); gettext(i,y-1,i,y-1,&t); t.attr=0x4f; puttext(i,y-1,i,y-1,&t); } gotoxy(3,y-1); return; }
    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1