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

各位高人好:请帮小妹妹运行运行下面的程序,为什么不单击菜单不能出现其子菜单呢?
我用TC2.0编的。函数名就是函数的意思!
#include<graphics.h>
#include<dos.h>
#include<conio.h>
#include<stdlib.h>
struct menu{
int left,top,right,bottom;
char *head;
};
struct menu File={150,90,200,110,"File"};
struct menu Edit={250,90,300,110,"Edit"};
struct menu Help={350,90,400,110,"Help"};
struct menu Close={620,20,630,30,"x"};
struct menu Title={100,20,540,50};
struct menu Mainmenu={100,70,540,120};
struct menu Text={100,150,540,450};
struct menu Print={50,455,590,475};
union REGS i,o;
int button,x,y;
void show_mouse(void);
void set_fill_screen(void);
void process_program(void);
void set_title_screen(struct menu *t);
void set_mainmenu_screen(struct menu *t);
void set_text_screen(struct menu *t);
void set_print_screen(struct menu *t);
void comment(void);
void draw_button(struct menu *t);
void status_mouse(void);
int mouse_on(struct menu *t);
void display_sub_menu(struct menu *t,int n,char *ff[]);
void high_light(struct menu *t);
int main(void)
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc");
show_mouse();
set_fill_screen();
process_program();
getch();
closegraph();
return 0;
}
void show_mouse(void)
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void set_fill_screen(void)
{
setfillstyle(1,3);
bar(0,0,640,480);
clrscr();
}
void process_program(void)
{
char KEY;
char *fm[]={"New","Open","Save","Save as","Exit"};
char *em[]={"Undo","Cut","Copy","Paste","Delete","Select All"};
char *hm[]={"Help Topics","About Menus"};
set_title_screen(&Title);
set_mainmenu_screen(&Mainmenu);
set_text_screen(&Text);
set_print_screen(&Print);
comment();
draw_button(&File);
draw_button(&Edit);
draw_button(&Help);
draw_button(&Close);
while(1)
{
status_mouse();
if(button==1)
{
if(mouse_on(&File))
display_sub_menu(&File,5,fm);
if(mouse_on(&Edit))
display_sub_menu(&Edit,6,em);
if(mouse_on(&Help))
display_sub_menu(&Help,2,hm);
if(mouse_on(&Close))
break;
}
else
{
if(mouse_on(&File))
high_light(&File);
if(mouse_on(&Edit))
high_light(&Edit);
if(mouse_on(&Help))
high_light(&Help);
if(mouse_on(&Close))
high_light(&Close);
}
if(kbhit())
{
KEY=getch();
if(KEY==27)
break;
}
}/*while*/
} /*process_program*/
void set_title_screen(struct menu *t)
{
setfillstyle(1,0);
bar(t->left,t->top,t->right,t->bottom);
setcolor(0);
line(t->left,t->top,t->right,t->top);
line(t->left,t->top,t->left,t->bottom);
setcolor(15);
line(t->right,t->top,t->right,t->bottom);
line(t->left,t->bottom,t->right,t->bottom);
}
void set_mainmenu_screen(struct menu *t)
{
setcolor(15);
line(t->left,t->top,t->right,t->top);
line(t->left,t->top,t->left,t->bottom);
setcolor(0);
line(t->right,t->top,t->right,t->bottom);
line(t->left,t->bottom,t->right,t->bottom);
}
void set_text_screen(struct menu *t)
{
setfillstyle(1,2);
bar(t->left,t->top,t->right,t->bottom);
setcolor(0);
line(t->left,t->top,t->right,t->top);
line(t->left,t->top,t->left,t->bottom);
setcolor(15);
line(t->left,t->bottom,t->right,t->bottom);
line(t->right,t->top,t->right,t->bottom);
}
void set_print_screen(struct menu *t)
{
setfillstyle(1,0);
bar(t->left,t->top,t->right,t->bottom);
setcolor(0);
line(t->left,t->top,t->right,t->top);
line(t->left,t->top,t->left,t->bottom);
setcolor(15);
line(t->left,t->bottom,t->right,t->bottom);
line(t->right,t->top,t->right,t->bottom);
}
void comment(void)
{
char text_string1[]="This is my first graph menu!";
char text_string2[]="Hello Friend!";
char text_string3[]="Here is an with my menu program.";
char text_string4[]="As you can see it's like windows menu ,you can";
char text_string5[]="add more menus to it.It's just a concept for";
char text_string6[]="build more menus.I hope you will like my effort,";
char text_string7[]="email me at : chentianqiao06@163.com.";
char text_string8[]="__chentianqiao.";
char text_string9[]="2006-03-01.";
setcolor(15);
outtextxy(200,30,text_string1);
outtextxy(150,170,text_string2);
outtextxy(150,190,text_string3);
outtextxy(150,210,text_string4);
outtextxy(150,230,text_string5);
outtextxy(150,250,text_string6);
outtextxy(150,270,text_string7);
outtextxy(390,290,text_string8);
outtextxy(390,310,text_string9);
}
void draw_button(struct menu *t)
{
setcolor(0);
outtextxy(t->left+2,t->top+2,t->head);
}
void status_mouse(void)
{
i.x.ax=3;
int86(0x33,&i,&o);
button=o.x.bx;
x=o.x.cx;
y=o.x.dx;
}
int mouse_on(struct menu *t)
{
int flag=0;
if(x>=t->left && x<=t->right && y>=t->top && y<=t->bottom)
flag=1;
return flag;
}
void display_sub_menu(struct menu *t,int n,char *tt[])
{
int i;
unsigned area;
void *mapbuffer;
area=imagesize(100,120,540,450);
mapbuffer=malloc(area);
getimage(100,120,540,450,mapbuffer);
setfillstyle(1,3);
bar(t->left,t->top+30,t->right+50,t->bottom+150);
setcolor(15);
line(t->left,t->top+30,t->right+50,t->top+30);
line(t->left,t->top+30,t->left+30,t->bottom+150);
setcolor(0);
line(t->left,t->bottom+150,t->right+50,t->bottom+150);
line(t->right+50,t->top+30,t->right+50,t->bottom+150);
for(i=0;i<=n-1;i++)
{
setcolor(0);
outtextxy(t->left+5,t->top+i*20,tt[i]);
}
sleep(3);
putimage(100,120,mapbuffer,COPY_PUT);
free(mapbuffer);
}
void high_light(struct menu *t)
{
setcolor(15);
line(t->left,t->top,t->right,t->top);
line(t->left,t->top,t->left,t->bottom);
setcolor(0);
line(t->left,t->bottom,t->right,t->bottom);
line(t->right,t->top,t->right,t->bottom);
while(1) /*detect mouse state*/
{
status_mouse();
if(mouse_on(t)!=1)
{
setcolor(3);
rectangle(t->left,t->top,t->right,t->bottom);
break;
}
}
}

搜索更多相关主题的帖子: 菜单 menu struct 
2006-03-01 16:31
khhily
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-2-20
收藏
得分:0 
这么多,看得头晕了
还没到这境界,

2006-03-02 00:36
moon
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-3-5
收藏
得分:0 

......................

我写的一个画图软件的菜单~ 你可以参考一下!
整个软件:http://impact.ik8.com/mysoft.rar


/*文件菜单*/
void mefile(void)
{
int f;
void *buf;

buf=mygimg(9, 29, 82, 132);
setviewport(9, 29, 82, 132, 1);
setfillstyle(1,8);
bar(3, 3, 73, 103);
setfillstyle(1,7);
bar(0, 0, 70, 100);
setcolor(15);
rectangle(0, 0, 70, 100);

setcolor(0);
outtextxy(3, 5,"New [n]");
outtextxy(3, 65,"Init [i]");
outtextxy(3, 80,"Exit [x]");


setcolor(8);
outtextxy(3, 20,"Open.. [o]");
outtextxy(3, 35,"Save.. [s]");
outtextxy(3, 50,"-----------");

f=getch();
mypimg(9, 29,buf);
switch(f)
{
case 'n': {mefnew(); break;}
case 'i': {mefini(); break;}
case 'x': {mefext(); break;}
case 'o': break;
case 's': break;
}

setviewport(ZTSX, ZTSY, ZTXX, ZTXY, 1);
settextstyle(font, 0, csize);
setfillstyle(fully,color1);
setcolor(color0);

}


ARM+LINUX嵌入式   -月满西楼
2006-03-05 15:43
快速回复:紧急求助!菜单制作程序!
数据加载中...
 
   



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

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