标题:紧急求助!鼠标编程问题!
只看楼主
梦想中国
Rank: 2
等 级:新手上路
威 望:5
帖 子:539
专家分:0
注 册:2006-2-26
 问题点数:0 回复次数:2 
紧急求助!鼠标编程问题!

各位高人好:那位能帮我看看下面的程序怎么回事,我想将鼠标放在FILE和EDIT上面使起菜单高亮,为什么不行啊!
#include<graphics.h>
#include<dos.h>
struct MENU{
int left,top,right,bottom;
char *head;
};
struct MENU VIEW={100,100,450,300}; /*窗口大小*/
struct MENU FILE={150,150,200,180,"File"}; /*文件子窗口*/
struct MENU EDIT={210,150,260,180,"Edit"}; /*编辑子窗口*/
union REGS i,o;
int button,x,y; /*全局变量*/
void ShowMouse(void); /*显示鼠标函数*/
void StatusMouse(void); /*鼠标状态函数*/
void Process(void); /*处理函数*/
void createbar(struct MENU *t); /*创建窗口函数*/
void createline(struct MENU *t); /*创建窗口亮度函数*/
void outmenufile(struct MENU *t); /*输出文本函数*/
void outmenuedit(struct MENU *t); /*同上*/
int MouseOn(struct MENU *t); /*鼠标操作函数*/
void Hlight(struct MENU *t); /*显示高亮函数*/
void winp(struct MENU *t,int status); /*同上*/
int main(void)
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc");
Process();
getch();
closegraph();
return 0;
}
void Process(void)
{
createbar(&VIEW);
createbar(&FILE);
createbar(&EDIT);
createline(&VIEW);
outmenufile(&FILE);
outmenuedit(&EDIT);
ShowMouse();
StatusMouse();
if(MouseOn(&FILE))
Hlight(&FILE);
if(MouseOn(&EDIT))
Hlight(&EDIT);
}
void createbar(struct MENU *t)
{
setfillstyle(1,7);
bar(t->left,t->top,t->right,t->bottom);
}
void createline(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);
}
void outmenufile(struct MENU *t)
{
setcolor(0);
outtextxy(155,155,t->head);
}
void outmenuedit(struct MENU *t)
{
setcolor(0);
outtextxy(215,155,t->head);
}
void ShowMouse(void)
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void StatusMouse(void)
{
i.x.ax=3;
int86(0x33,&i,&o);
button=o.x.bx;
x=o.x.cx;
y=o.x.dx;
}
int MouseOn(struct MENU *t)
{
int flag;
flag=0;
if(x>=t->left && x<=t->right && y>=t->top && y<=t->bottom)
flag=1;
return flag;
}
void Hlight(struct MENU *t)
{
winp(t,0);
}
void winp(struct MENU *t,int state)
{
if(state==1)
{
setcolor(0);
line(t->left,t->top,t->left,t->bottom);
line(t->left,t->top,t->right,t->top);
setcolor(15);
line(t->right,t->top,t->right,t->bottom);
line(t->left,t->bottom,t->right,t->bottom);
}
else
{
setcolor(15);
line(t->left,t->top,t->left,t->bottom);
line(t->left,t->top,t->right,t->top);
setcolor(0);
line(t->right,t->top,t->right,t->bottom);
line(t->left,t->bottom,t->right,t->bottom);
}

}
那位帮我看看

搜索更多相关主题的帖子: 鼠标 MENU struct void 
2006-02-27 13:52
Knocker
Rank: 8Rank: 8
等 级:贵宾
威 望:47
帖 子:10454
专家分:603
注 册:2004-6-1
得分:0 

#include<graphics.h>
#include<dos.h>
struct MENU
{
int left,top,right,bottom ;
char*head ;
}
;
struct MENU VIEW=
{
100,100,450,300
}
;
/*窗口大小*/
struct MENU FILE=
{
150,150,200,180,"File"
}
;
/*文件子窗口*/
struct MENU EDIT=
{
210,150,260,180,"Edit"
}
;
/*编辑子窗口*/
union REGS i,o ;
int button,x,y ;
/*全局变量*/
void ShowMouse(void);
/*显示鼠标函数*/
void StatusMouse(void);
/*鼠标状态函数*/
void Process(void);
/*处理函数*/
void createbar(struct MENU*t);
/*创建窗口函数*/
void createline(struct MENU*t);
/*创建窗口亮度函数*/
void outmenufile(struct MENU*t);
/*输出文本函数*/
void outmenuedit(struct MENU*t);
/*同上*/
int MouseOn(struct MENU*t);
/*鼠标操作函数*/
void Hlight(struct MENU*t);
/*显示高亮函数*/
void winp(struct MENU*t,int status);
/*同上*/
void Process1(void);
int main(void)
{
int gdriver=DETECT,gmode ;
initgraph(&gdriver,&gmode,"c:\\tc");
Process();
while(1)Process1();
getch();
closegraph();
return 0 ;
}
void Process(void)
{
createbar(&VIEW);
createbar(&FILE);
createbar(&EDIT);
createline(&VIEW);
outmenufile(&FILE);
outmenuedit(&EDIT);


}
void Process1(void)
{
ShowMouse();
StatusMouse();
if(MouseOn(&FILE))
Hlight(&FILE);
if(MouseOn(&EDIT))
Hlight(&EDIT);

}
void createbar(struct MENU*t)
{
setfillstyle(1,7);
bar(t->left,t->top,t->right,t->bottom);
}
void createline(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);
}
void outmenufile(struct MENU*t)
{
setcolor(0);
outtextxy(155,155,t->head);
}
void outmenuedit(struct MENU*t)
{
setcolor(0);
outtextxy(215,155,t->head);
}
void ShowMouse(void)
{
i.x.ax=1 ;
int86(0x33,&i,&o);
}
void StatusMouse(void)
{
i.x.ax=3 ;
int86(0x33,&i,&o);
button=o.x.bx ;
x=o.x.cx ;
y=o.x.dx ;
}
int MouseOn(struct MENU*t)
{
int flag ;
flag=0 ;
if(x>=t->left&&x<=t->right&&y>=t->top&&y<=t->bottom)
flag=1 ;
return flag ;
}
void Hlight(struct MENU*t)
{
winp(t,0);
}
void winp(struct MENU*t,int state)
{
if(state==1)
{
setcolor(0);
line(t->left,t->top,t->left,t->bottom);
line(t->left,t->top,t->right,t->top);
setcolor(15);
line(t->right,t->top,t->right,t->bottom);
line(t->left,t->bottom,t->right,t->bottom);
}
else
{
setcolor(15);
line(t->left,t->top,t->left,t->bottom);
line(t->left,t->top,t->right,t->top);
setcolor(0);
line(t->right,t->top,t->right,t->bottom);
line(t->left,t->bottom,t->right,t->bottom);
}

}

程式结构有些混乱,问题原因代码已经告诉你了


九洲方除百尺冰,映秀又遭蛮牛耕。汽笛嘶鸣国旗半,哀伤尽处是重生。     -老K
治国就是治吏。礼义廉耻,国之四维。四维不张,国之不国。   -毛泽东
2006-02-27 19:23
梦想中国
Rank: 2
等 级:新手上路
威 望:5
帖 子:539
专家分:0
注 册:2006-2-26
得分:0 
2楼的绝对是高手

2006-02-27 19:32



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




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

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