标题:俺老师留的一个题目:整个下拉菜单!
取消只看楼主
zy1437zy
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-4-25
 问题点数:0 回复次数:1 
俺老师留的一个题目:整个下拉菜单!

#include<graphics.h>
#include<conio.h>
#include<stdio.h>
#include<bios.h>
#define L 0x4b00
#define R 0x4d00
#define U 0x4800
#define D 0x5000
#define ESC 0x11b
int X=0,Y=0;
unsigned KEY;
char MENU[4][3][6]={{"str00\0","str01\0","str02\0"},{"str10\0","str11\0","str12\0"},{"str20\0","str21\0","str22\0"},{"str30\0","str31\0","str32\0"}};
void main()
{
void draw(int a,int b,int sign);
void crtview(void);
void draw1(int a,int b,int sign);

int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"d:\\tc2");
setbkcolor(EGA_BLUE);
setfillstyle(SOLID_FILL,EGA_WHITE);
bar(0,0,639,19);
bar(0,459,639,479);
setcolor(EGA_WHITE);
rectangle(4,24,634,454);
setcolor(EGA_BLUE);
outtextxy(249,464,"MADE BY ZY");
getch();

for(X=0,Y=0;X<=3;X++)
draw(X,Y,EGA_WHITE);

X=0;
Y=0;
draw(X,Y,EGA_RED);
while(1)
{
KEY=bioskey(0);
switch(KEY)
{
case L:
if(X==0)break;
else
{
if(Y!=0)
{
clearviewport();
setcolor(EGA_WHITE);
line(-5,4,634,4);
Y=0;
graphdefaults();
setbkcolor(EGA_BLUE);
}
draw(X,Y,EGA_WHITE);
X--;
draw(X,Y,EGA_RED);
}
break;
case R:
if(X==3)break;
else
{
if(Y!=0)
{
clearviewport();
setcolor(EGA_WHITE);
line(-5,4,634,4);
Y=0;
graphdefaults();
setbkcolor(EGA_BLUE);
}

draw(X,Y,EGA_WHITE);
X++;
draw(X,Y,EGA_RED);
break;
}
case U:
if(Y==0)break;
else
{ if(Y==2)
{
draw1(X,Y,EGA_WHITE);
Y--;
draw1(X,Y,EGA_GREEN);
break;
}
else
break;
}
case D:
if(Y==2)break;
else
{
if(Y==0)
{
crtview();
break;
}
else
{
draw1(X,Y,EGA_WHITE);
Y++;
draw1(X,Y,EGA_GREEN);
break;
}
}
case ESC:
closegraph();
return;
default:
break;
}
}
}
void draw(int a,int b,int sign)
{
setfillstyle(SOLID_FILL,sign);
bar(49+a*100,0,49+(a+1)*100,19);
if(sign==EGA_WHITE)
sign=EGA_RED;
else
sign=EGA_WHITE;
setcolor(sign);
outtextxy(49+a*100,5,MENU[a][b]);
}
void crtview(void)
{
setviewport(49+X*100,20,149+X*100,20*3,1);
setfillstyle(SOLID_FILL,EGA_WHITE);
bar(0,0,99,39);
for(Y=1;Y<=2;Y++)
draw1(X,Y,EGA_WHITE);
Y=1;
draw1(X,Y,EGA_GREEN);
}
void draw1(int a,int b,int sign)
{
setfillstyle(SOLID_FILL,sign);
bar(0,(Y-1)*20,100,Y*20);
if(sign==EGA_WHITE)
sign=EGA_RED;
else
sign=EGA_BLUE;
setcolor(sign);
outtextxy(0,5+(b-1)*20,MENU[a][b]);
}

搜索更多相关主题的帖子: void 菜单 define 
2007-05-06 14:26
zy1437zy
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-4-25
得分:0 
没什么含量也没 做什么优化改动及添加注释!
就是在网上找了半天没找到需要的;
就自己弄了 一个
希望给一些同学一点思路!
请 多指教!~
2007-05-06 14:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-137227-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.100977 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved