/*对该站的建议:希望下载能够开放些,真的很想要那些东东啊!可我现在还不是高级会员。5~~5~~~~*/
#include "conio.h"
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "dos.h"
#include "bios.h"
#define F1 0x3b00
#define F2 0x3c00
#define F3 0x3d00
#define F4 0x3e00
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define SPACE 0x3920
#define ESC 0x011b
#define ENTER 0x1c0d
int CurX=2,CurY=4;
static char MenuName1[10]="File";
static char MenuName3[12]="Option";
static char MenuName2[14]="fUnction";
static char MenuName4[10]="Help";
static char OptionMenu1[3][7]={"O1Mnu1",
"O2Mnu1",
"O3Mnu1"
};
static char OptionMenu2[3][9]={" O1Mnu2 ",
" O2Mnu2 ",
" O3Mnu2 "
};
static char OptionMenu3[3][9]={" O1Mnu3 ",
" O2Mnu3 ",
" O3Mnu3 "
};
static char OptionMenu4[3][9]={" O1Mnu4 ",
" O2Mnu4 ",
" O3Mnu4 "
};
int getkey(int *key)/*显示时间函数*/
{struct time aa;
int a,b;
char time[20];
gettime(&aa);/*获取时间*/
a=aa.ti_sec;
while(!kbhit())
{
gettime(&aa);
b=aa.ti_sec;
if(abs(b-a)>=1)
{
a=b;
sprintf(time,"%02d:%02d:%02d",aa.ti_hour,aa.ti_min,aa.ti_sec);
gotoxy(70,25);
textbackground(0);
textcolor(YELLOW);
cputs(time);
gotoxy(CurX,CurY); /* else cur stin on the right of time */
}
}
*key=bioskey(0);
}
DisplayMenu(int PosMenu,int PosOption)
{
int VarX,VarY,Var;
switch(PosMenu)
{
case 1:{
gotoxy(7,1);
textcolor(WHITE);
textbackground(BLACK); /*显示菜单1的名字,其背景色相对初始界面改变*/
cprintf("%s",MenuName1);
textcolor(BLACK);textbackground(7);
for(VarX=7;VarX<=13;VarX++)
{gotoxy(VarX,2); /*menu1box画上边框*/
cprintf("%c",196);
gotoxy(VarX,6);
cprintf("%c",196); /*menu1box画下边框*/
}
for(VarY=3;VarY<=5;VarY++)
{gotoxy(6,VarY);
cprintf("%c",179);
gotoxy(14,VarY);
cprintf("%c",179);
}
gotoxy(14,6);
cprintf("%c",217); /*右下角*/
gotoxy(6,2);
cprintf("%c",218);/*左上角*/
gotoxy(6,6);
cprintf("%c",192);/*左下角*/
gotoxy(14,2);
cprintf("%c",191);/*右上角*/
/***显示各个菜单1的项目***/
for(Var=0;Var<3;Var++)
{gotoxy(6+2,2+Var+1);
cprintf("%s",&OptionMenu1[Var][0]);
}
/***显示菜单1选中选项的内容***/
gotoxy(6+1,2+PosOption);
textbackground(BLACK);
textcolor(WHITE);
cprintf("%s",&OptionMenu1[PosOption-1][0]);
gotoxy(CurX,CurY);
break;
}
case 2:{
gotoxy(27,1);
textcolor(WHITE);
textbackground(BLACK); /*显示菜单2的名字,其背景色相对初始界面改变*/
cprintf("%s",MenuName2);
textcolor(BLACK);textbackground(7);
for(VarX=27;VarX<=34;VarX++)
{gotoxy(VarX,2); /*menu1box画上边框*/
cprintf("%c",196);
gotoxy(VarX,6);
cprintf("%c",196); /*menu1box画下边框*/
}
for(VarY=2;VarY<=5;VarY++)
{gotoxy(26,VarY);
cprintf("%c",179);
gotoxy(35,VarY);
cprintf("%c",179);
}
gotoxy(35,6);
cprintf("%c",217); /*右下角*/
gotoxy(26,2);
cprintf("%c",218);/*左上角*/
gotoxy(26,6);
cprintf("%c",192);/*左下角*/
gotoxy(35,2);
cprintf("%c",191);/*右上角*/
/***显示各个菜单2的项目***/
for(Var=0;Var<3;Var++)
{gotoxy(27,Var+3);
cprintf("%s",&OptionMenu2[Var][0]);
}
/***显示菜单2选中选项的内容***/
gotoxy(26+1,2+PosOption);
textbackground(BLACK);
textcolor(WHITE);
cprintf("%s",&OptionMenu2[PosOption-1][0]);
gotoxy(CurX,CurY);
break;
}
case 3:{
gotoxy(47,1);
textcolor(WHITE);
textbackground(BLACK); /*显示菜单3的名字,其背景色相对初始界面改变*/
cprintf("%s",MenuName3);
textcolor(BLACK);textbackground(7);
for(VarX=47;VarX<=54;VarX++)
{gotoxy(VarX,2); /*menu1box画上边框*/
cprintf("%c",196);
gotoxy(VarX,6);
cprintf("%c",196); /*menu1box画下边框*/
}
for(VarY=3;VarY<=5;VarY++)
{gotoxy(46,VarY);
cprintf("%c",179);
gotoxy(55,VarY);
cprintf("%c",179);
}
gotoxy(55,6);
cprintf("%c",217); /*右下角*/
gotoxy(46,2);
cprintf("%c",218);/*左上角*/
gotoxy(46,6);
cprintf("%c",192);/*左下角*/
gotoxy(55,2);
cprintf("%c",191);/*右上角*/
/***显示各个菜单3的项目***/
for(Var=0;Var<3;Var++)
{gotoxy(47,Var+3);
cprintf("%s",&OptionMenu3[Var][0]);
}
/***显示菜单3选中选项的内容***/
gotoxy(46+1,2+PosOption);
textbackground(BLACK);
textcolor(WHITE);
cprintf("%s",&OptionMenu3[PosOption-1][0]);
gotoxy(CurX,CurY);
break;
}
case 4:{
gotoxy(67,1);
textcolor(WHITE);
textbackground(BLACK); /*显示菜单1的名字,其背景色相对初始界面改变*/
cprintf("%s",MenuName4);
textcolor(BLACK);textbackground(7);
for(VarX=67;VarX<=74;VarX++)
{gotoxy(VarX,2); /*menu1box画上边框*/
cprintf("%c",196);
gotoxy(VarX,6);
cprintf("%c",196); /*menu1box画下边框*/
}
for(VarY=3;VarY<=5;VarY++)
{gotoxy(66,VarY);
cprintf("%c",179);
gotoxy(75,VarY);
cprintf("%c",179);
}
gotoxy(75,6);
cprintf("%c",217); /*右下角*/
gotoxy(66,2);
cprintf("%c",218);/*左上角*/
gotoxy(66,6);
cprintf("%c",192);/*左下角*/
gotoxy(75,2);
cprintf("%c",191);/*右上角*/
/***显示各个菜单4的项目***/
for(Var=0;Var<3;Var++)
{gotoxy(67,2+Var+1);
cprintf("%s",&OptionMenu4[Var][0]);
}
/***显示菜单1选中选项的内容***/
gotoxy(67,2+PosOption);
textbackground(BLACK);
textcolor(WHITE);
cprintf("%s",&OptionMenu4[PosOption-1][0]);
gotoxy(CurX,CurY);
break;
}
default:break;
}/*end of switch(PosMenu)*/
}
main()
{
int key,VarX,VarY,PosMenu,PosOption;
char textSave[4096];
clrscr();
textbackground(BLUE);
for(VarY=1;VarY<=25;VarY++) /*设置背景颜色*/
{
for(VarX=1;VarX<=80;VarX++)
{
gotoxy(Var
X,VarY);
cprintf("%c",0);
}
}
textcolor(7); /*7为淡灰色*/
for(VarX=1;VarX<=80;VarX++) /*画上面和下面的两条粗线*/
{
gotoxy(VarX,1);
cprintf("%c",219);
gotoxy(VarX,25);
if(VarX!=80) /*a bug 否则翻页,怎么克服? */
cprintf("%c",219);
}
gotoxy(2,25); /*底部的关于热操作的提示*/
textcolor(RED);
textbackground(7);
cprintf("F1"); /*其对应功能还未实现*/
textcolor(BLACK);
cprintf("-Help");
textcolor(RED);
cprintf(" F2");
textcolor(BLACK);
cprintf("-Check X");
textcolor(RED);
cprintf(" F3");
textcolor(BLACK);
cprintf("-Check FD format");
textcolor(RED);
cprintf(" F4");
textcolor(BLACK);
cprintf("-Check FD element");
textbackground(BLUE);
textcolor(7);
for(VarX=1;VarX<=80;VarX++) /*增加的RESULT框开始*/
{
gotoxy(VarX,22);
cprintf("%c",196);
}
gotoxy(37,22);
cprintf("RESULT"); /*增加的RESULT框结束*/
for(VarX=2;VarX<=79;VarX++) /*画边框*/
{
gotoxy(VarX,2); /*上边框*/
cprintf("%c",205);
}
cprintf("%c",184); /*框的右上角*/
gotoxy(1,2);
cprintf("%c",213); /*框的左上角*/
for(VarY=3;VarY<=23;VarY++)
{
gotoxy(1,VarY); /*框左边框*/
cprintf("%c",179);
gotoxy(80,VarY); /*框右边框*/
cprintf("%c",179);
}
cprintf("%c",192); /*框左下角*/
for(VarX=2;VarX<=79;VarX++) /*下边框*/
cprintf("%c",196);
gotoxy(80,24);
cprintf("%c",217); /*框右下角*/
gotoxy(35,2);
cprintf(" Message ");
/*以下是菜单文字*/
textcolor(BLACK);
textbackground(7);
gotoxy(7,1);
cprintf("%s",MenuName1);
gotoxy(27,1);
cprintf("%s",MenuName2);
gotoxy(47,1);
cprintf("%s",MenuName3);
gotoxy(67,1);
cprintf("%s",MenuName4);
textcolor(RED); /**********************************/
gotoxy(7,1);cprintf("F");
gotoxy(28,1);cprintf("U");
gotoxy(47,1);cprintf("O");
gotoxy(67,1);cprintf("H");
gotoxy(2,3);
gotoxy(25,24);
/*开始的问候语*/
textcolor(7);
for(VarX=30;VarX<=50;VarX++) /*开始的问候语的底色*/
{
for(VarY=8;VarY<=12;VarY++)
{
gotoxy(VarX,VarY);
cprintf("%c",219);
}
}
textcolor(0); /*开始的问候语的字体颜色4为红*/
textbackground(7); /*开始的问候语的字体背景色7为灰色*/
for(VarX=31;VarX<=49;VarX++) /*开始画问候语边框*/
{
gotoxy(VarX,8); /*上框*/
cprintf("%c",196);
gotoxy(VarX,12); /*下框*/
cprintf("%c",196);
}
gotoxy(30,8);
cprintf("%c",218); /*左上角*/
gotoxy(50,8);
cprintf("%c",191); /*右上角*/
gotoxy(30,12);
cprintf("%c",192); /*左下角*/
gotoxy(50,12);
cprintf("%c",217); /*右下角*/
for(VarY=9;VarY<=11;VarY++)
{
gotoxy(30,VarY); /*左框*/
cprintf("%c",179);
gotoxy(50,VarY); /*右框*/
cprintf("%c",179);
} /*画问候语边框结束*/
gotoxy(34,8);
cprintf("CAIdb-Ver1.0");
gotoxy(32,10);
cprintf(" Welcome !");
gotoxy(41,12);
cprintf("2003-7-23");
gotoxy(2,4);textbackground(BLUE);textcolor(BLUE); /*******消除光标************/
getkey(&key);/*时间函数调用*/
textbackground(BLUE); /*用来将问候语的那部分地方重新设置为蓝色*/
textcolor(7);
gotoxy(30,10);
cprintf(" ");
gotoxy(30,8);
cprintf(" ");
gotoxy(30,12);
cprintf(" ");
gotoxy(30,9);
cprintf(" ");
gotoxy(30,11);
cprintf(" ");/*问候语言结束*/
/***初始化界面和问候语结束***/
gotoxy(2,4);
while(1) /*界面操作大循环开始*/
{Start:
getkey(&key);
/*组合键操作表 */
if(key==0x2100) goto Menu1; /* ALT+F 进入菜单1 FILE */
if(key==0x1600) goto Menu2; /* ALT+U 进入菜单2 FUNC */
if(key==0x1800) goto Menu3; /* ALT+O 进入菜单3 Optn */
if(key==0x2300) goto Menu4; /* ALT+H 进入菜单4 HELP */
if(key==0x2d00) exit(0); /* Alt+X 退出*/
switch(key)
{
case F1: /*菜单1的操作开始*/
{Menu1:
PosMenu=1; /*初始化菜单位置*/
PosOption=1; /*初始化选项位置*/
gettext(1,1,80,25,textSave);
DisplayMenu(PosMenu,PosOption);
gotoxy(2,4);
while(1) /*菜单1里的循环操作*/
{
getkey(&key);
switch(key)
{case DOWN:
{
if(PosOption==3) break;
else{
PosOption++;
DisplayMenu(PosMenu,PosOption);gotoxy(CurX,CurY);
}
}
case UP:
{
if(PosOption==1) break;
else{
PosOption--;
DisplayMenu(PosMenu,PosOption); gotoxy(CurX,CurY);break;
}
}
case ENTER: /*选定菜单内容*/
{ puttext(1,1,80,25,textSave);
switch(PosOption)
{case 1:
{textcolor(YELLOW); textbackground(BLUE);
gotoxy(2,4);cprintf("Access Menu1_Option1");/***执行菜单1的第1项所对应的功能***/
break;
}
case 2:
{gotoxy(2,4);/***执行菜单1的第2项所对应的功能***/
textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu1_Option2");
break;
}
case 3:{
exit(0);
}
}gotoxy(CurX,CurY);
goto Start;
}
case ESC: /*假如按ESC键的话退出菜单并恢复原貌*/
{
puttext(1,1,80,25,textSave);gotoxy(CurX,CurY);
goto Start;
}
case RIGHT: {puttext(1,1,80,25,textSave);
goto Menu2;
}
case LEFT: {puttext(1,1,80,25,textSave);
goto Menu4;
}
default: break;/*其他的键就继续*/
}/*end 菜单内1 switch() */
} /*菜单1里的大while(1)循环结束*/
break; }/*end case F1 */
/* 第二个菜单选项开始 */
case F2:
{Menu2:
PosMenu=2;PosOption=1;
gettext(1,1,80,25,textSave);
DisplayMenu(PosMenu,PosOption);
gotoxy(2,4);
while(1) /*菜单里的循环操作*/
{
getkey(&key);
switch(key)
{
case DOWN:{if(PosOption==3) continue;
else
{
PosOption++;gotoxy(CurX,CurY);
DisplayMenu(PosMenu,PosOption);break;
}
}
case UP:
{if(PosOption==1) continue;
else
{
PosOption--;gotoxy(CurX,CurY);
DisplayMenu(PosMenu,PosOption);break;
}
}
case ENTER:
{ puttext(1,1,80,25,textSave);
switch(PosOption)
{case 1:
{gotoxy(2,4);textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu2_Option1"); /***执行菜单2选项1所对应功能***/
break;
}
case 2:
{gotoxy(2,
4);textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu2_Option2");
break;
}
case 3: { gotoxy(2,4);textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu2_theLastOption");
break;
}
}gotoxy(CurX,CurY);
goto Start;
}
case ESC: /*按ESC键退出菜单并恢复原貌*/
{
puttext(1,1,80,25,textSave);gotoxy(CurX,CurY);
goto Start;
}
case LEFT:{puttext(1,1,80,25,textSave);
goto Menu1;
}
case RIGHT:{puttext(1,1,80,25,textSave);
goto Menu3;
}
default: break;
}/*end 菜单2内switch*/
}/*end while(1)*/
break; }/*end case F2 */
/*********第三个菜单选项开始*********/
case F3:
{Menu3:
PosMenu=3;PosOption=1;
gettext(1,1,80,25,textSave);
DisplayMenu(PosMenu,PosOption);
gotoxy(2,4);
while(1)
{
getkey(&key);
switch(key)
{
case DOWN:
{
if(PosOption==3) break;
else
{
PosOption++;gotoxy(CurX,CurY);
DisplayMenu(PosMenu,PosOption);break;
}
}
case UP:
{
if(PosOption==1) break;
else
{
PosOption--;gotoxy(CurX,CurY);
DisplayMenu(PosMenu,PosOption);break;
}
}
case ENTER:
{puttext(1,1,80,25,textSave);
switch(PosOption)
{case 1:
{gotoxy(2,4);textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu3 Option1");/***执行菜单3选项1功能***/
break;
}
case 2:{gotoxy(2,4);textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu3 Option2");
break;
}
case 3:{gotoxy(2,4);textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu3 the last Option");
break;
}
}gotoxy(CurX,CurY);
goto Start;
}
case ESC:
{
puttext(1,1,80,25,textSave);gotoxy(CurX,CurY);
goto Start;
}
case LEFT:{puttext(1,1,80,25,textSave);
goto Menu2;
}
case RIGHT:{puttext(1,1,80,25,textSave);
goto Menu4;
}
default: break;;
}/*end菜单3内switch()*/
}/*end while(1) */
break; } /*end case F3 */
case F4:
{Menu4:
PosMenu=4;PosOption=1;
gettext(1,1,80,25,textSave);
DisplayMenu(PosMenu,PosOption);
gotoxy(2,4);
while(1)
{getkey(&key);
switch(key)
{
case DOWN:{if(PosOption==3) break;
else
{
PosOption++;gotoxy(CurX,CurY);
DisplayMenu(PosMenu,PosOption);break;
}
}
case UP:
{if(PosOption==1) break;
else
{
PosOption--;gotoxy(CurX,CurY);
DisplayMenu(PosMenu,PosOption);break;
}
}
case ENTER:{puttext(1,1,80,25,textSave);
switch(PosOption)
{
case 1:{gotoxy(2,4);textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu4 Option 1\n");
break;
}
case 2:{gotoxy(2,4);textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu4 Option 2\n");
break;
}
case 3:{gotoxy(2,4);textcolor(YELLOW); textbackground(BLUE);
cprintf("Access Menu4 the last Option\n");
break;
}
gotoxy(CurX,CurY);
}
goto Start;
}
case LEFT:{ puttext(1,1,80,25,textSave);
goto Menu3;
}
case RIGHT:{puttext(1,1,80,25,textSave);
goto Menu1;
}
case ESC:{puttext(1,1,80,25,textSave);gotoxy(CurX,CurY);
goto Start;
}
default: break;
}/*end 菜单4内 switch*/
}/*end while */
break; }/*end case F4 */
/*这些键盘盘的功能尚未开放*/
case 0x3f00: break;;
case 0x4000: break;;
case 0x4100: break;;
case 0x4200: break;;
case 0x4300: break;;
case ESC: break;
case 0x4400: /*F10*/ break;;
case 0xf09: /*Tab*/ break;;
case 0x5200: /*insert*/ break;;
case 0x4900: /*pageup*/ break;;
case 0x5300: /*delete*/ break;;
case 0x5100: /*page down*/ break;; /*以上是尚未开放的功能键*/
case UP:
{
if(CurY==4) break;
CurY--;
gotoxy(CurX,CurY);break;
}
case DOWN:
{
if(CurY==21) break;
CurY++;
gotoxy(CurX,CurY);break;
}
case LEFT:
{
if(CurX==2) break;
CurX--;
gotoxy(CurX,CurY);break;
}
case RIGHT:
{
if(CurX==78) break;
CurX++;
gotoxy(CurX,CurY);break;
}
case SPACE:
{
if(CurX==78) break;
else
{textcolor(YELLOW);
gotoxy(CurX,CurY); /*空格的细节操作*/
printf(" ");
CurX++;
gotoxy(CurX,CurY);break;
}
}
case ENTER:
{
if(CurY==21) break;
CurY++;
CurX=2;
gotoxy(CurX,CurY);break;
}
case 0xe08: /* BSP <- */
{
if(CurX==2&&CurY==4) break;
else
{
if(CurX!=2) CurX--; /*擦除键的细节问题,先擦去东西,然后光标还要往后退一格*/
else
{
CurX=78;
CurY--;
}
gotoxy(CurX,CurY);
printf(" ");/*擦除*/
gotoxy(CurX,CurY);break;
}
}
case 0x4700: /* Home */
{
CurX=2;
CurY=4;
gotoxy(CurX,CurY);break;
}
case 0x4f00: /* End */
{
CurX=78;
CurY=21;
gotoxy(CurX,CurY);break;
}
default:
{
if(CurX==78&&CurY==21) break;
else if(CurX==78) /*到行的最后*/
{
CurY++;
CurX=2;
}
gotoxy(CurX,CurY);/*输出结果*/
textcolor(YELLOW);textbackground(BLUE);
cprintf("%c",key);
if(CurX==78) break;
else {CurX++;break;}
}
}/*end 界面switch(key) */
}/*while(1)*/
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |