分享一下 toubor c 界面
#include<dos.h>
#include<bios.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define SPACE 0x3920
#define Esc 0x011b
#define ENTER 0x1c0d
#define Backspace 0xe08
#define ALT_B 12288
#define ALT_M 12800
#define ALT_H 8960
int key;
int textx,texty;
struct menustruct
{
char name[10];
char str[10][20];
int n;
}ml[3];
typedef struct BookList
{
char num[20];
char name[20];
int price;
char person[20];
int yes;
struct BookList *next;
}Book;
typedef struct MemberList
{
char name[20];
char sex[2];
int age;
struct MenberList *next;
}Menber;
char save[4906];
char c[4906];
int i,j;
void Menu();
void Selectitem();
void DrawSelectitem();
void BlackText(int x,int y,char *z);
void RedText(int x,int y,char *z);
void Run();
void DrawMl(int n);
void MoveMl(int n,int x);
void Enter(int m,int n);
void BookAdd();
void BookConsult();
void BookDel();
void BookBorrow();
void BookReturn();
void MemberAdd();
void MemberConsult();
void MemberDel();
void MemberBook();
void Help();
void Ver();
void ClrScr();
void DrawFrame(int left,int up,int right,int down,int textcolor,int backgroundcolor);
void main()
{
Menu();
Run();
}
void Menu()
{
system("cls");
textbackground(BLUE);
window(1,1,25,80);
clrscr();
textx=3;
texty=2;
gotoxy(1,2);
printf("%c",218);
for(i=0;i<78;i++)
printf("%c",196);
printf("%c",191);
for(i=3;i<=23;i++)
{
gotoxy(1,i);
printf("%c",179);
gotoxy(80,i);
printf("%c",179);
}
printf("%c",192);
for(i=0;i<78;i++)
printf("%c",196);
printf("%c",217);
gotoxy(1,1);
textcolor(7);
for(i=0;i<80;i++)
cprintf("%c",219);
Selectitem();
DrawSelectitem();
gettext(2,3,78,23,c);
}
void Selectitem()
{
strcpy(ml[0].name,"Book");
strcpy(ml[0].str[0],"Add ");
strcpy(ml[0].str[1],"Consult ");
strcpy(ml[0].str[2],"Del ");
strcpy(ml[0].str[3],"Borrow ");
strcpy(ml[0].str[4],"Return ");
strcpy(ml[0].str[5],"Exit ");
ml[0].n=6;
strcpy(ml[1].name,"Member");
strcpy(ml[1].str[0],"Add ");
strcpy(ml[1].str[1],"Consult ");
strcpy(ml[1].str[2],"Del ");
strcpy(ml[1].str[3],"Member&book ");
ml[1].n=4;
strcpy(ml[2].name,"Help");
strcpy(ml[2].str[0],"This System ");
strcpy(ml[2].str[1],"Ver ");
strcpy(ml[2].str[2],"register ");
ml[2].n=3;
}
void DrawSelectitem()
{
for(i=0;i<3;i++)
RedText(i,1,ml[i].name);
}
void RedText(int x,int y,char *z)
{
textbackground(7);
gotoxy(3+x*20,y);
for(j=0;z[j];j++)
{
if(j==0)
textcolor(RED);
else
textcolor(BLACK);
cprintf("%c",z[j]);
}
}
void BlackText(int x,int y,char *z)
{
textbackground(0);
textcolor(15);
gotoxy(3+20*x,y);
cputs(z);
}
void Run()
{
while(1)
{
gotoxy(texty,textx);
key=bioskey(0);
switch(key)
{
case ALT_B:DrawMl(0);break;
case Esc:DrawMl(0);break;
case ALT_M:DrawMl(1);break;
case ALT_H:DrawMl(2);break;
case UP:
{
if(textx==3)
textx=23;
textx--;
gotoxy(texty,textx);
}break;
case DOWN:
{
if(textx==23)
textx=3;
textx++;
gotoxy(texty,textx);
}break;
case LEFT:
{
if(texty==2)
texty=79;
texty--;
gotoxy(texty,textx);
}break;
case Backspace:
{
if(texty==2&&textx==3)
continue;
else
{
if(texty!=2)
texty--;
else
if(texty==2)
{
texty=78;
textx--;
}
gotoxy(texty,textx);
printf(" ");
gotoxy(texty,textx);
}
}break;
case RIGHT:
{
if(texty==79)
texty=2;
texty++;
gotoxy(texty,textx);
}break;
case SPACE:
if(texty==79)
continue;
else
{
gotoxy(texty,textx);
printf(" ");
texty++;
gotoxy(texty,textx);
}
break;
case ENTER:
{
if(textx==23)
continue;
textx++;
texty=2;
gotoxy(texty,textx);
}break;
default:
{
if(texty==79&&textx==23)
continue;
else
if(texty==79&&textx!=23)
{textx++;
texty=2;
}
gotoxy(texty,textx);
printf("%c",key);
if(texty==79)
continue;
else
texty++;
}
}
}
}
void DrawFrame(int l,int u,int r,int d,int tcolor,int bcolor)
{
textbackground(bcolor);
textcolor(bcolor);
for(i=l;i<=r;i++)
{
for(j=u;j<=d;j++)
{
gotoxy(i,j);
printf("%c",219);
}
}
textcolor(tcolor);
for(i=u+1;i<d;i++)
{
gotoxy(l,i);
cprintf("%c",179);
gotoxy(r,i);
cprintf("%c",179);
}
for(i=l+1;i<r;i++)
{
gotoxy(i,u);
cprintf("%c",196);
gotoxy(i,d);
cprintf("%c",196);
}
gotoxy(l,u);
cprintf("%c",218);
gotoxy(r,u);
cprintf("%c",191);
gotoxy(l,d);
cprintf("%c",192);
gotoxy(r,d);
cprintf("%c",217);
}
void DrawMl(int n)
{
gettext(1,1,80,25,save);
BlackText(n,1,ml[n].name);
DrawFrame(3+20*n-1,2,3+20*n+19,3+ml[n].n,0,7);
for(i=3;i<3+ml[n].n;i++)
{
if(i==3)
BlackText(n,i,ml[n].str[i-3]);
else
RedText(n,i,ml[n].str[i-3]);
}
gotoxy(79,1);
MoveMl(n,3);
}
void MoveMl(int n,int x)
{
int flag=1;
while(flag)
{
gotoxy(79,1);
key=bioskey(0);
gotoxy(79,1);
switch(key)
{
case Esc:
puttext(1,1,80,25,save);
flag=0;
break;
case LEFT:
puttext(1,1,80,25,save);
if(n==0)
DrawMl(2);
else
DrawMl(n-1);
flag=0;
break;
case RIGHT:
puttext(1,1,80,25,save);
if(n==2)
DrawMl(0);
else
DrawMl(n+1);
flag=0;
break;
case UP:
RedText(n,x,ml[n].str[x-3]);
if(x==3)
x=3+ml[n].n-1;
else
x--;
BlackText(n,x,ml[n].str[x-3]);
flag=1;
break;
case DOWN:
RedText(n,x,ml[n].str[x-3]);
if(x==(3+ml[n].n-1))
x=3;
else
x++;
BlackText(n,x,ml[n].str[x-3]);
flag=1;
break;
case ENTER:
puttext(1,1,80,25,save);
Enter(n,x-3);
flag=0;
break;
}
gotoxy(79,1);
}
}
void Enter(int m,int n)
{
}
#include<dos.h>
#include<bios.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define SPACE 0x3920
#define Esc 0x011b
#define ENTER 0x1c0d
#define Backspace 0xe08
#define ALT_B 12288
#define ALT_M 12800
#define ALT_H 8960
int key;
int textx,texty;
struct menustruct
{
char name[10];
char str[10][20];
int n;
}ml[3];
typedef struct BookList
{
char num[20];
char name[20];
int price;
char person[20];
int yes;
struct BookList *next;
}Book;
typedef struct MemberList
{
char name[20];
char sex[2];
int age;
struct MenberList *next;
}Menber;
char save[4906];
char c[4906];
int i,j;
void Menu();
void Selectitem();
void DrawSelectitem();
void BlackText(int x,int y,char *z);
void RedText(int x,int y,char *z);
void Run();
void DrawMl(int n);
void MoveMl(int n,int x);
void Enter(int m,int n);
void BookAdd();
void BookConsult();
void BookDel();
void BookBorrow();
void BookReturn();
void MemberAdd();
void MemberConsult();
void MemberDel();
void MemberBook();
void Help();
void Ver();
void ClrScr();
void DrawFrame(int left,int up,int right,int down,int textcolor,int backgroundcolor);
void main()
{
Menu();
Run();
}
void Menu()
{
system("cls");
textbackground(BLUE);
window(1,1,25,80);
clrscr();
textx=3;
texty=2;
gotoxy(1,2);
printf("%c",218);
for(i=0;i<78;i++)
printf("%c",196);
printf("%c",191);
for(i=3;i<=23;i++)
{
gotoxy(1,i);
printf("%c",179);
gotoxy(80,i);
printf("%c",179);
}
printf("%c",192);
for(i=0;i<78;i++)
printf("%c",196);
printf("%c",217);
gotoxy(1,1);
textcolor(7);
for(i=0;i<80;i++)
cprintf("%c",219);
Selectitem();
DrawSelectitem();
gettext(2,3,78,23,c);
}
void Selectitem()
{
strcpy(ml[0].name,"Book");
strcpy(ml[0].str[0],"Add ");
strcpy(ml[0].str[1],"Consult ");
strcpy(ml[0].str[2],"Del ");
strcpy(ml[0].str[3],"Borrow ");
strcpy(ml[0].str[4],"Return ");
strcpy(ml[0].str[5],"Exit ");
ml[0].n=6;
strcpy(ml[1].name,"Member");
strcpy(ml[1].str[0],"Add ");
strcpy(ml[1].str[1],"Consult ");
strcpy(ml[1].str[2],"Del ");
strcpy(ml[1].str[3],"Member&book ");
ml[1].n=4;
strcpy(ml[2].name,"Help");
strcpy(ml[2].str[0],"This System ");
strcpy(ml[2].str[1],"Ver ");
strcpy(ml[2].str[2],"register ");
ml[2].n=3;
}
void DrawSelectitem()
{
for(i=0;i<3;i++)
RedText(i,1,ml[i].name);
}
void RedText(int x,int y,char *z)
{
textbackground(7);
gotoxy(3+x*20,y);
for(j=0;z[j];j++)
{
if(j==0)
textcolor(RED);
else
textcolor(BLACK);
cprintf("%c",z[j]);
}
}
void BlackText(int x,int y,char *z)
{
textbackground(0);
textcolor(15);
gotoxy(3+20*x,y);
cputs(z);
}
void Run()
{
while(1)
{
gotoxy(texty,textx);
key=bioskey(0);
switch(key)
{
case ALT_B:DrawMl(0);break;
case Esc:DrawMl(0);break;
case ALT_M:DrawMl(1);break;
case ALT_H:DrawMl(2);break;
case UP:
{
if(textx==3)
textx=23;
textx--;
gotoxy(texty,textx);
}break;
case DOWN:
{
if(textx==23)
textx=3;
textx++;
gotoxy(texty,textx);
}break;
case LEFT:
{
if(texty==2)
texty=79;
texty--;
gotoxy(texty,textx);
}break;
case Backspace:
{
if(texty==2&&textx==3)
continue;
else
{
if(texty!=2)
texty--;
else
if(texty==2)
{
texty=78;
textx--;
}
gotoxy(texty,textx);
printf(" ");
gotoxy(texty,textx);
}
}break;
case RIGHT:
{
if(texty==79)
texty=2;
texty++;
gotoxy(texty,textx);
}break;
case SPACE:
if(texty==79)
continue;
else
{
gotoxy(texty,textx);
printf(" ");
texty++;
gotoxy(texty,textx);
}
break;
case ENTER:
{
if(textx==23)
continue;
textx++;
texty=2;
gotoxy(texty,textx);
}break;
default:
{
if(texty==79&&textx==23)
continue;
else
if(texty==79&&textx!=23)
{textx++;
texty=2;
}
gotoxy(texty,textx);
printf("%c",key);
if(texty==79)
continue;
else
texty++;
}
}
}
}
void DrawFrame(int l,int u,int r,int d,int tcolor,int bcolor)
{
textbackground(bcolor);
textcolor(bcolor);
for(i=l;i<=r;i++)
{
for(j=u;j<=d;j++)
{
gotoxy(i,j);
printf("%c",219);
}
}
textcolor(tcolor);
for(i=u+1;i<d;i++)
{
gotoxy(l,i);
cprintf("%c",179);
gotoxy(r,i);
cprintf("%c",179);
}
for(i=l+1;i<r;i++)
{
gotoxy(i,u);
cprintf("%c",196);
gotoxy(i,d);
cprintf("%c",196);
}
gotoxy(l,u);
cprintf("%c",218);
gotoxy(r,u);
cprintf("%c",191);
gotoxy(l,d);
cprintf("%c",192);
gotoxy(r,d);
cprintf("%c",217);
}
void DrawMl(int n)
{
gettext(1,1,80,25,save);
BlackText(n,1,ml[n].name);
DrawFrame(3+20*n-1,2,3+20*n+19,3+ml[n].n,0,7);
for(i=3;i<3+ml[n].n;i++)
{
if(i==3)
BlackText(n,i,ml[n].str[i-3]);
else
RedText(n,i,ml[n].str[i-3]);
}
gotoxy(79,1);
MoveMl(n,3);
}
void MoveMl(int n,int x)
{
int flag=1;
while(flag)
{
gotoxy(79,1);
key=bioskey(0);
gotoxy(79,1);
switch(key)
{
case Esc:
puttext(1,1,80,25,save);
flag=0;
break;
case LEFT:
puttext(1,1,80,25,save);
if(n==0)
DrawMl(2);
else
DrawMl(n-1);
flag=0;
break;
case RIGHT:
puttext(1,1,80,25,save);
if(n==2)
DrawMl(0);
else
DrawMl(n+1);
flag=0;
break;
case UP:
RedText(n,x,ml[n].str[x-3]);
if(x==3)
x=3+ml[n].n-1;
else
x--;
BlackText(n,x,ml[n].str[x-3]);
flag=1;
break;
case DOWN:
RedText(n,x,ml[n].str[x-3]);
if(x==(3+ml[n].n-1))
x=3;
else
x++;
BlackText(n,x,ml[n].str[x-3]);
flag=1;
break;
case ENTER:
puttext(1,1,80,25,save);
Enter(n,x-3);
flag=0;
break;
}
gotoxy(79,1);
}
}
void Enter(int m,int n)
{
}





2008-8-5 16:54