www.pudn.com > c.rar > MENU.C, change:1996-12-22,size:10544b


#include "dos.h" 
#include "conio.h" 
#include "graphics.h" 
#include "stdio.h" 
#include "stdlib.h" 
#define ESC 283 
#define HOME 18176 
#define END 20224 
#define LEFT 19200 
#define RIGHT 19712 
#define INS 20992 
#define DEL 21248 
#define UP 18432 
#define DOWN 20480 
#define RETERN 7181 
#define BACK 3592 
unsigned char dot[24][3]; 
unsigned char dot1[16][2]; 
FILE *fp1; 
FILE *fp; 
void hz_single1(int x,int y,int m,int n,int col); 
void hz_string1(char *s,int x,int y,int m,int n,int col); 
void hz_single(int x,int y,int m, int n, int col); 
void box(int,int,int,int,int); 
void box1(int,int,int,int,int); 
void hz_string(char *s,int x,int y, int m,int n,int col); 
int menubox(int x,int y); 
int litil(int x,int y,int ln,int ht,int aa); 
int choice_menu(int,int); 
int inputproc(int,int); 
void promenu(void); 
void beforebox(void); 
main() 
{ 
int graphdrive=DETECT,graphmode=2; 
clrscr(); 
initgraph(&graphdrive,&graphmode,""); 
setviewport(0,0,639,479,0); 
setfillstyle(1,7); 
floodfill(1,1,4); 
setviewport(3,3,637,477,1); 
box(15,6,630,463,2); 
setviewport(15,15,620,460,1); 
promenu(); 
menubox(20,6); 
closegraph(); 
restorecrtmode(); 
} 
/**************************************************************/ 
void hz_string(char *s,int x,int y,int m,int n,int col) 
{ 
long offset1; 
if ((fp=fopen("c:\\ucdos\\hzk24f","rb"))==NULL) 
   { 
   restorecrtmode(); 
   printf("cannot open the file hzk24f\007\n"); 
   exit(0); 
   } 
while(*s) 
{ 
offset1=(long)((*s+95-15)*94+(*(s+1)+95))*72; 
fseek(fp,offset1,SEEK_SET); 
hz_single(x,y,m,n,col); 
x+=24; 
s+=2; 
} 
rewind(fp); 
fclose(fp); 
} 
/******************************************************************/ 
void hz_single(int x,int y,int m,int n,int col) 
{ 
register i,j,k,mm,nn,mask; 
for(i=0;i<=23;i++) 
   { 
   for(j=0;j<=2;j++) 
      { 
      dot[i][j]=getc(fp); 
      mask=0x80; 
      for(k=0;k<=7;k++) 
	 { 
	 if(dot[i][j]&mask) 
	   { 
	   for(mm=0;mm<m;mm++) 
	      { 
	      for(nn=0;nn<n;nn++) 
	      putpixel(x+i*m+mm,y+(j*8+k)*n+nn,col); 
	      } 
	    } 
	    mask=mask>>1; 
	    } 
	} 
   } 
} 
/******************************************************************/ 
void box(int x,int y,int ln,int ht,int aa) 
{ 
register x1,y1; 
x1=x-15; 
ln=ln+5; 
ht=ht+8; 
y1=(y-1)-5; 
switch(aa) 
{ 
case 1: 
setcolor(15); 
moveto(x1+1,y1+1); 
lineto(x1+ln-1,y1+1); 
moveto(x1+2,y1+2); 
lineto(x1+ln-2,y1+2); 
moveto(x1+1,y1+1); 
lineto(x1+1,y1+ht-1); 
moveto(x1+2,y1+2); 
lineto(x1+2,y1+ht-2); 
setcolor(DARKGRAY); 
moveto(x1+ln,y1+ht); 
lineto(x1+ln,y1); 
moveto(x1+ln,y1+ht); 
lineto(x1,y1+ht); 
moveto(x1+ln-1,y1+ht-1); 
lineto(x1+ln-1,y1+1); 
moveto(x1+ln-1,y1+ht-1); 
lineto(x1+1,y1+ht-1); 
moveto(x1+ln-2,y1+ht-2); 
lineto(x1+ln-2,y1+2); 
moveto(x1+ln-2,y1+ht-2); 
lineto(x1+2,y1+ht-2); 
moveto(x1+ln-3,y1+ht-3); 
lineto(x1+3,y1+ht-3); 
break; 
case 2: 
setcolor(DARKGRAY); 
moveto(x1,y1); 
lineto(x1+ln,y1); 
moveto(x1,y1); 
lineto(x1,y1+ht); 
moveto(x1+1,y1); 
lineto(x1+ln-1,y1+1); 
moveto(x1+2,y1+2); 
lineto(x1+ln-2,y1+2); 
moveto(x1+1,y1+1); 
lineto(x1+1,y1+ht-1); 
moveto(x1+2,y1+2); 
lineto(x1+2,y1+ht-2); 
setcolor(WHITE); 
moveto(x1+ln,y1+ht); 
lineto(x1+ln,y1); 
moveto(x1+ln,y1+ht); 
lineto(x1,y1+ht); 
moveto(x1+ln-1,y1+ht-1); 
lineto(x1+ln-1,y1+1); 
moveto(x1+ln-1,y1+ht-1); 
lineto(x1+1,y1+ht-1); 
moveto(x1+ln-2,y1+ht-2); 
lineto(x1+ln-2,y1+2); 
moveto(x1+ln-2,y1+ht-2); 
lineto(x1+2,y1+ht-2); 
moveto(x1+ln-3,y1+ht-3); 
lineto(x1+3,y1+ht-3); 
break; 
case 6: 
setcolor(12); 
rectangle(x1+2,y1+2,x1+ln-2,y1+ht-2); 
break; 
} 
} 
/******************************************************************/ 
void box1(int x,int y,int ln,int ht,int aa) 
{ 
int i; 
register x1,y1; 
x1=x-15; 
ln=ln+5; 
ht=ht+8; 
y1=(y-1)-5; 
setcolor(aa); 
rectangle(x1+2,y1+2,x1+ln-2,y1+ht-2); 
rectangle(x1+2,y1+3,x1+ln-2,y1+ht-3); 
} 
/******************************************************************/ 
int menubox(int x1,int y1) 
{ 
int x2,y2; 
int loop=1,n,i, aa=9,loop1=1; 
int n1; 
register int x3,y3; 
y2=y1+5;x3=x1;y3=y1; 
do{ 
  box(x3,y3,96,30,6); 
  n=bioskey(0); 
  switch(n) 
       { 
       case RIGHT: 
       x3+=103; 
       ++aa; 
       if(aa==12)aa=13; 
       if(aa>15)aa=9; 
       if(aa<9)aa=15; 
       if(x3>540){x3=20;box(535,y3,96,30,1);} 
       if(x3<540) 
       box(x3-103,y3,96,30,1); 
       box(x3,y3,96,30,6); 
       break; 
       case LEFT: 
       x3-=103; 
       --aa; 
       if(aa<9)aa=15; 
       if(aa==12)aa=11; 
       if(aa>15)aa=9; 
       if(x3<18){x3=535;box(20,y3,96,30,1);} 
       if(x3>18) 
       box(x3+103,y3,96,30,1); 
       box(x3,y3,96,30,6); 
       break; 
       case ESC: 
       loop1=0; 
       goto lab; 
       case RETERN: 
       n1=3; 
       sound(1000); 
       box(x3,y3,96,30,2); 
       nosound(); 
       setviewport(6,50,632,380,1); 
       litil(x3,y3+2,96,160,aa); 
       inputproc(x3,y2); 
       box(x3,y2,96,30,6); 
do{ 
loop=1; 
n=bioskey(0); 
switch(n) 
      { 
      case RETERN: 
      box(x3,y2,96,30,6); 
      setviewport(8,10,630,450,1); 
      clearviewport(); 
      restorecrtmode(); 
      x2=x3; 
      choice_menu(x2,y2); 
      loop=0; 
      beforebox(); 
      promenu(); 
      break; 
      case UP: 
      y2-=30; 
      if(y2>4)box1(x3,y2+30,96,30,aa); 
      if(y2<4){y2=131;box1(x3,y1+5,96,30,aa);} 
      box(x3,y2,96,30,6); 
      break; 
      case DOWN: 
      y2+=30; 
      if(y2<135)box1(x3,y2-30,96,30,aa); 
      if(y2>135){y2=y1+5;box1(x3,131,96,30,aa);} 
      box(x3,y2,96,30,6); 
      break; 
      case ESC: 
      if(n1==3)clearviewport();n1=0; 
      setviewport(8,10,630,450,1); 
      sound(1000); 
      box(x3,y1,96,30,1); 
      nosound(); 
      box(x3,y1,96,30,6); 
      loop=0; 
      break; 
      case RIGHT: 
      clearviewport(); 
      setviewport(8,10,630,450,1); 
      x3+=103; 
      if(x3>540){x3=20;box(535,y3,96,30,1);aa=8;} 
      if(x3<540){box(x3-103,y3,96,30,1);} 
      sound(1000); 
      box(x3,y3,96,30,2); 
      nosound(); 
      setviewport(6,50,632,380,1); 
      ++aa; 
      if(aa==12)aa=13; 
      if(aa>15)aa=9; 
      litil(x3,y3+2,96,160,aa); 
      inputproc(x3,y2); 
      box(x3,y2,96,30,6); 
      break; 
      case LEFT: 
      clearviewport(); 
      setviewport(8,10,630,450,1); 
      x3-=103; 
      if(x3<10){x3=535;box(20,y3,96,30,1);aa=16;} 
      if(x3>10)box(x3+103,y3,96,30,1); 
      sound(1000); 
      box(x3,y3,96,30,1); 
      nosound(); 
      setviewport(6,50,632,380,1); 
      --aa; 
      if(aa==12)aa=11; 
      if(aa>15)aa=9; 
      litil(x3,y3+2,96,160,aa); 
      inputproc(x3,y2); 
      box(x3,y2,96,30,6); 
      break; 
      default:continue; 
      } 
      }while(loop); 
      break;} 
      }while(loop1); 
      lab: 
      return; 
} 
/*****************************************************************/ 
void beforebox() 
{ 
int gdriver=DETECT,gmode=2; 
clrscr(); 
initgraph(&gdriver,&gmode,""); 
setcolor(LIGHTGRAY); 
setbkcolor(DARKGRAY); 
setviewport(0,0,639,479,0); 
setfillstyle(1,7); 
floodfill(1,1,4); 
setviewport(3,3,637,477,1); 
box(15,6,630,463,2); 
} 
/*************************************************************/ 
void promenu() 
{ 
char *s="结构设计计算",*s1="",*s2="工具",\ 
*s3="数据输送",*s4="",*s5="退出",\ 
*s6="退出",*s7="确认",*s8="结构设计平台"; 
setviewport(8,10,630,450,1); 
sound(1000); 
box(20,6,96,30,1); 
nosound(); 
hz_string1(s,9,11,1,1,9); 
sound(1000); 
box(123,6,96,30,1); 
nosound(); 
hz_string1(s1,112,11,1,1,10); 
sound(1000); 
box(226,6,96,30,1); 
nosound(); 
hz_string1(s2,215,11,1,1,11); 
sound(1000); 
box(329,6,96,30,1); 
nosound(); 
hz_string1(s3,318,11,1,1,13); 
sound(1000); 
box(432,6,96,30,1); 
nosound(); 
hz_string1(s4,421,11,1,1,14); 
sound(1000); 
box(535,6,96,30,1); 
nosound(); 
hz_string1(s5,524,11,1,1,15); 
box(50,410,96,30,1); 
settextstyle(0,HORIZ_DIR,1); 
outtextxy(50,420,"ESC"); 
hz_string1(s6,97,415,1,1,12); 
box(180,410,290,30,1); 
hz_string(s8,195,411,1,1,10); 
box(505,410,96,30,1); 
outtextxy(505,420,"ENTER"); 
hz_string1(s7,551,415,1,1,12); 
} 
/************************************************************/ 
int litil(int x,int y, int ln,int ht,int aa) 
{ 
int x1,y1; 
x1=x-15; 
ln=ln+5;ht=ht+8;y1=(y-1)-5; 
setbkcolor(LIGHTGRAY); 
setcolor(DARKGRAY); 
moveto(x1+10,y1+10); 
lineto(x1+ln+10,y1+10); 
moveto(x1+10,y1+10); 
lineto(x1+10,y1+ht+10); 
moveto(x1+10,y1+ht+10); 
lineto(x1+ln+10,y1+ht+10); 
moveto(x1+ln+10,y1+10); 
lineto(x1+ln+10,y1+ht+10); 
setfillstyle(1,8); 
floodfill(x1+11,y1+11,8); 
setcolor(aa); 
moveto(x1,y1); 
lineto(x1+ln,y1); 
moveto(x1,y1); 
lineto(x1,y1+ht); 
moveto(x1,y1+ht); 
lineto(x1+ln,y1+ht); 
moveto(x1+ln,y1); 
lineto(x1+ln,y1+ht); 
setfillstyle(1,aa); 
floodfill(x1+1,y1+1,aa); 
} 
/*************************************************/ 
void hz_string1(char *s,int x,int y,int m,int n,int col) 
{ 
long offset1; 
if((fp1=(fopen("c:\\ucdos\\hzk16","rb")))==NULL) 
  { 
  restorecrtmode(); 
  printf("cannot open the file hzk16\n"); 
  exit(1); 
  } 
while(*s) 
{ 
offset1=(long)((*s+95)*94+(*(s+1)+95))*32; 
fseek(fp1,offset1,SEEK_SET); 
hz_single1(x,y,m,n,col); 
x+=16*n; 
s+=2; 
} 
rewind(fp1); 
fclose(fp1); 
} 
/****************************************************/ 
void hz_single1(int x,int y,int m,int n,int col) 
{ 
register i,j,k,mm,nn,mask; 
for(i=0;i<=15;i++) 
  { 
  for(j=0;j<=1;j++) 
     { 
     dot[i][j]=getc(fp1); 
     mask=0x80; 
     for(k=0;k<=7;k++) 
	{ 
	if(dot[i][j]&mask) 
	    { 
	    for(nn=0;nn<n;nn++) 
	       { 
	       for(mm=0;mm<m;mm++) 
	       putpixel(x+(j*8+k)*n+nn,y+i*m+mm,col); 
	       } 
	} 
	mask=mask>>1; 
     } 
     } 
     } 
} 
/******************************************************/ 
int inputproc(int x3,int y2) 
{ 
FILE *fp3; 
char *s1="                               ",*s2="                           "; 
int x4,y4; 
if((fp3=fopen("proc.dat","r"))==NULL) 
{ 
restorecrtmode(); 
printf("cannot open the file proc.dat"); 
exit(0); 
} 
rewind(fp3); 
do{ 
if(feof(fp3))goto lab; 
fscanf(fp3,"%3d%3d%s%s\n",&x4,&y4,s1,s2); 
if(x3==x4)hz_string1(s1,x4-10,y4+5,1,1,0); 
}while(1); 
lab: 
rewind(fp3); 
fclose(fp3); 
return y2; 
} 
int choice_menu(int x3,int y2) 
{ 
FILE *fp4; 
char *s1="                         ",*s2="                                 "; 
int x4,y4; 
if((fp4=(fopen("proc.dat","rb")))==NULL) 
{ 
restorecrtmode(); 
printf("cannot open the file proc.dat"); 
exit(1); 
} 
rewind(fp4); 
do{ 
if(feof(fp4))goto lab; 
fscanf(fp4,"%3d%3d%s%s\n",&x4,&y4,s1,s2); 
if(x4==x3) 
{ 
if(y4==y2) 
{ 
system(s2); 
getch(); 
goto lab; 
} 
} 
}while(1); 
lab: 
rewind(fp4); 
fclose(fp4); 
return(1); 
}