| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 523 人关注过本帖
标题:来看看这个程序!
只看楼主 加入收藏
梦想中国
Rank: 2
等 级:新手上路
威 望:5
帖 子:539
专家分:0
注 册:2006-2-26
收藏
 问题点数:0 回复次数:2 
来看看这个程序!

大家运行运行下面的程序,看看什么地方错了,为什么只能输入一次。
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
struct MENU{
int left,top,right,bottom;
char *head;
};
struct MENU File={120,120,170,140,"FILE"};
struct MENU Edit={175,120,225,140,"EDIT"};
struct MENU Help={230,120,280,140,"HELP"};
unsigned area;
void *mapbuffer;
void createview(void);
void Process(void);
void instructions(void);
void createline(int x1,int y1,int x2,int y2);
void createsubview(void);
void createmenu(void);
void output(struct MENU *t);
void PullMenuDown(struct MENU *t);
void createsubview(void);
void submenu(struct MENU *t,int n,char *tm[]);
void text(void);
int main(void)
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc");
Process();
closegraph();
return 0;
}
void Process(void)
{
char *fm[]={"New","Open","Save","Save as","Exit"}; /*argument=five*/
char *em[]={"Undo","Cut","Copy","Paste","Delete","Select All"}; /*argument=six*/
char *hm[]={"Help Topics","About Menus"}; /*argument=two*/
int choice;
createview();
createline(100,100,400,150); /*create sub view*/
createmenu();
createsubview();
text();
instructions();
scanf("%d",&choice);
while(choice!=0)
{
switch(choice)
{
case 1:
PullMenuDown(&File);
submenu(&File,5,fm);
sleep(2);
putimage(100,100,mapbuffer,COPY_PUT);
break;
case 2:
PullMenuDown(&Edit);
submenu(&Edit,6,em);
sleep(2);
putimage(100,100,mapbuffer,COPY_PUT);
break;
case 3:
PullMenuDown(&Help);
submenu(&Help,2,hm);
sleep(2);
putimage(100,100,mapbuffer,COPY_PUT);
break;
default:
printf("Invalid enter.\n");
break;
}
printf("%c ",'?');
scanf("%d",&choice);
}
}
void createview(void)
{
setfillstyle(1,7);
bar(50,50,450,400);
createline(50,50,450,400);
}
void createline(int x1,int y1,int x2,int y2)
{
setcolor(15);
line(x1,y1,x2,y1);
line(x1,y1,x1,y2);
setcolor(0);
line(x2,y1,x2,y2);
line(x1,y2,x2,y2);
}
void instructions(void)
{
printf("Enter your choice.\n"
"1-PullFileMenuDown.\n"
"2-PullEditMenuDown.\n"
"3-PullHelpMenuDown.\n"
"4-Exit.\n");
}
void createmenu(void)
{
output(&File);
output(&Edit);
output(&Help);
}
void output(struct MENU *t)
{
setcolor(0);
outtextxy(t->left+5,t->top,t->head);
}
void createsubview(void)
{
setfillstyle(1,2);
bar(100,160,400,350);
createline(100,160,400,350);
}
void PullMenuDown(struct MENU *t)
{
area=imagesize(100,100,400,300);
mapbuffer=malloc(area);
getimage(100,100,400,300,mapbuffer);
setfillstyle(1,7);
bar(t->left,t->top+20,t->right+50,t->bottom+120);
createline(t->left,t->top+20,t->right+50,t->bottom+120);
}
void submenu(struct MENU *t,int n,char *tm[])
{
int i,high=30;
for(i=0;i<=n-1;i++)
{
setcolor(0);
outtextxy(t->left+10,t->top+high,tm[i]);
high+=20;
}

}
void text(void)
{
char textstring1[]={"This is my first graph."};
char textstring2[]={"I think you like."};
char textstring3[]={"My name is chentianqiao."};
char textstring4[]={"Bye-Bye."};
setcolor(0);
outtextxy(120,220,textstring1);
outtextxy(120,240,textstring2);
outtextxy(120,260,textstring3);
outtextxy(120,280,textstring4);
outtextxy(430,60,"x");
}



搜索更多相关主题的帖子: include bottom 
2006-02-26 19:30
cxwl3sxl
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:495
专家分:129
注 册:2005-11-12
收藏
得分:0 
好长哦!

努力,哈哈,总有一天会变成高手~~~~~~因为我相信:没有办不到,只有想不到!http://t..cn/fpress
2006-02-26 21:19
A15673328
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-2-26
收藏
得分:0 

看不懂

2006-02-26 23:56
快速回复:来看看这个程序!
数据加载中...
 
   



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

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