写字板界面部分函数不会写,帮忙
本程序的功能是实现写字板界面源代码有一部分,可是有部分函数没有代码
有六个函数根本不知道怎么写
MouseOn() COmments() End() Up() HandleMenu() Push()
望请指教
#include"conio.h"
#include"dos.h"
#include"graphics.h"
#include"stdio.h"
#include"stdlib.h"
#define NO 0
#define YES 1
#define NONE -1
#define MAX_MENU 7
int x,y;
int Selection;
int button;
void *p;
size_t area;
struct MENU
{
int x,y;
int x1,y1;
unsigned char Active[MAX_MENU];
char *head;
};
int MouseOn(struct MENU *t);
void Process();
void Msg(char *str);
void DrawBtn(struct MENU *tm,char *txt);
void winp(struct MENU *t,int state);
void Win(int sx,int sy,int ex,int ey);
void PullMenuDown(char *H[],int n,struct MENU *tm);
void PullMenuUp(int n,struct MENU *tm);
void Hlight(struct MENU *t);
void Xorbar(int sx,int sy,int ex,int ey,int c);
void Show();
void Hide();
void Status();
struct MENU File={200,110,250,130};
struct MENU Edit={295,110,345,130};
struct MENU Help={390,110,440,130};
struct MENU Close={600,10,620,30};
struct MENU Neeraj={380,300,460,315};
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\turboc2");
Selection=NONE;
for(gd=0;gd<MAX_MENU;gd++)
{
File.Active[gd]=YES;
Edit.Active[gd]=YES;
Help.Active[gd]=YES;
Close.Active[gd]=YES;
}
File.head="[File Menu]";
Edit.head="[Edit Menu]";
Help.head="[Help Menu]";
Close.head="[Exit]";
area=imagesize(0,0,150,150);
p=malloc(area);
if(p==NULL)
{
closegraph();
restorecrtmode();
printf("Not Enough Memory!\n Try to reduce the areaused.\n");
exit(1);
}
setfillstyle(1,7);
bar(0,0,640,480);
x=2;y=2;
Process();
End();
closegraph();
printf("GUI-MENUS By Neeraj Sharma - zmhdxy19870228@163.com\n");
getch();
}
void Process()
{
char *fm[]={"New","Open","save","save as","Exit"};
char *em[]={"Undo","Cut","Copy","Paste","Delete","Select All"};
char *hm[]={"Help Topics","About Menus"};
char KEY;
Win(140,100,500,140);
DrawBtn(&File,"File");
DrawBtn(&Edit,"Edit");
DrawBtn(&Help,"Help");
settextstyle(0,0,0);
outtextxy(Close.x+7,Close.y+7,"x");
Comments();
Show();
File.Active[3]=NO;
Edit.Active[0]=NO;
while(1)
{
if(kbhit())
{
KEY=getch();
if(KEY==27||KEY==45) break;
}
Status();
if(button==1)
{
if(MouseOn(&Close)) break;
if(MouseOn(&File))
{
PullMenuDown(fm,5,&File);
if(Selection==NONE) Msg("NO Selection!");
else
Msg("fm[Selection]");
if(Selection==4) break;
}
if(MouseOn(&Edit))
{
PullMenuDown(em,6,&Edit);
if(Selection==NONE) Msg("NO Selection!");
else
Msg("em[Selection]");
}
if(MouseOn(&Edit))
{
PullMenuDown(hm,2,&Help);
if(Selection==NONE) Msg("NO Selection!");
else
Msg("hm[Selection]");
if(Selection==1) Msg("*Programming By NEERAJ SHARMA*");
}
}
else
{
if(MouseOn(&File)) Hlight(&File);
if(MouseOn(&Edit)) Hlight(&Edit);
if(MouseOn(&Help)) Hlight(&Help);
if(MouseOn(&Close)) Hlight(&Close);
if(MouseOn(&Neeraj))
{
Msg("Hello,everyone");
while(MouseOn(&Neeraj))
{
Status();
if(button!=0) break;
if(kbhit()) break;
}
Msg("");
}
}
}
Msg("::Bye Bye::");
}
void Msg(char *str)
{
printf("%s",str);
}
void DrawBtn(struct MENU *tm,char *txt)
{
setcolor(0);
settextstyle(2,0,4);
outtextxy(tm->x+15,tm->y+4,txt);
}
void Hlight(struct MENU *t)
{
winp(t,0);
Msg(t->head);
while(MouseOn(t))
{
Status();
if(button!=0) break;
if(kbhit()) break;
}
setcolor(7);
Hide();
rectangle(t->x,t->y,t->x1,t->y1);
Msg("");
Show();
}
void winp(struct MENU *t,int state)
{
Hide();
if(state==1)
{
setcolor(0);
line(t->x,t->y,t->x,t->y1);
line(t->x,t->y,t->x1,t->y);
setcolor(15);
line(t->x,t->y,t->x1,t->y1);
line(t->x,t->y,t->x1,t->y1);
}
else
{
setcolor(15);
line(t->x,t->y,t->x,t->y1);
line(t->x,t->y,t->x1,t->y);
setcolor(0);
line(t->x1,t->y,t->x1,t->y1);
line(t->x,t->y1,t->x1,t->y1);
}
Show();
}
void Win(int sx,int sy,int ex,int ey)
{
Hide();
setfillstyle(1,7);
bar(sx,sy,ex,ey);
setcolor(15);
line(sx,sy,sx,ey);
line(sx,sy,ex,sy);
line(ex,sy,ex,sy);
line(sx,ey,ex,ey);
Show();
}
void PullMenuDown(char *H[],int n,struct MENU *tm)
{
int i;
i=n*20;
Push(tm);
Hide();
getimage(tm->x+1,tm->y1+2,tm->x+100,tm->y1+i+5,p);
setcolor(0);
settextstyle(2,0,4);
for(i=0;i<=n;i++)
{
if(!tm->Active[i])
{
setcolor(15);
outtextxy(tm->x+15,tm->y1+9+i*20,H[i]);
setcolor(0);
outtextxy(tm->x+14,tm->y1+8+i*20,H[i]);
}
else
outtextxy(tm->x+14,tm->y1+8+i*20,H[i]);
}
Show();
while(button==1) Status();
HandleMenu(n,tm);
}
void PullMenuUp(int n,struct MENU *tm)
{
int i;
Hide();
putimage(tm->x+1,tm->y1+2,p,COPY_PUT);
Show();
Up(tm);
}
union REGS i,o;
struct SREGS ss;
void Show()
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void Hide()
{
i.x.ax=2;
int86(0x33,&i,&o);
}
void Status()
{
i.x.ax=3;
int86(0x33,&i,&o);
button=o.x.bx;
x=o.x.cx;
y=o.x.dx;
}
----------------解决方案--------------------------------------------------------
人呢 高手呢 难道放假了
那我怎么办
不会是凉拌吧
----------------解决方案--------------------------------------------------------
重新改写了一下,帮忙啊
#include"conio.h" #include"dos.h"
#include"graphics.h"
#include"stdio.h"
#include"stdlib.h"
//定义一些常量
#define NO 0
#define YES 1
#define NONE -1
#define MAX_MENU 7//根据情况改变可以在菜单显示最大的项
//全局参数
int x,y;
int Selection;
int button;
void *p;
size_t area;
//菜单结构
struct MENU
{
int x,y;
int x1,y1;
unsigned char Active[MAX_MENU];//菜单项是否激活的标志
char *head;//菜单的名字(可选项)
};
int MouseOn(struct MENU *t);
void Process();
void Msg(char *str);
void DrawBtn(struct MENU *tm,char *txt);
void winp(struct MENU *t,int state);
void Win(int sx,int sy,int ex,int ey);
void PullMenuDown(char *H[],int n,struct MENU *tm);
void PullMenuUp(int n,struct MENU *tm);
void Hlight(struct MENU *t);
void Xorbar(int sx,int sy,int ex,int ey,int c);
void Show();
void Hide();
void Status();
//通过下面的参数可以改变菜单的位置
struct MENU File={200,110,250,130};
struct MENU Edit={295,110,345,130};
struct MENU Help={390,110,440,130};
struct MENU Close={600,10,620,30};
struct MENU Neeraj={380,300,460,315};
void main()
{
int gd=DETECT,gm;
//初始化图形界面
initgraph(&gd,&gm,"c:\\turboc2");
Selection=NONE;
//是否激活菜单项,YES表示激活,NO表示不激活
for(gd=0;gd <MAX_MENU;gd++)
{
File.Active[gd]=YES;
Edit.Active[gd]=YES;
Help.Active[gd]=YES;
Close.Active[gd]=YES;
}
//菜单项的名字,可以修改以显示其他的名称
File.head="[File Menu]";
Edit.head="[Edit Menu]";
Help.head="[Help Menu]";
Close.head="[Exit]";
//为界面分配内存
area=imagesize(0,0,150,150);
p=malloc(area);
//没有足够的内存
if(p==NULL)
{
closegraph();
restorecrtmode();
printf("Not Enough Memory!\n Try to reduce the areaused.\n");
exit(1);
}
setfillstyle(1,7);
bar(0,0,640,480);
x=2;y=2;
//绘制这个界面
Process();
End();
//关闭图形显示方式
closegraph();
printf("GUI-MENUS By Neeraj Sharma - zmhdxy19870228@163.com\n");
getch();
}
void Process()
{
//文件菜单项的子菜单项
char *fm[]={"New","Open","save","save as","Exit"};
char *em[]={"Undo","Cut","Copy","Paste","Delete","Select All"};
//编辑菜单项的子菜单项
char *hm[]={"Help Topics","About Menus"};
//如果改变了菜单项的值,那么也同样需要改变在
//函数中的PullMenuDown(char *,int)值
char KEY;
//绘制各个菜单
Win(140,100,500,140);
//绘制文件菜单项
DrawBtn(&File,"File");
//绘制编辑菜单项
DrawBtn(&Edit,"Edit");
//绘制帮助菜单项
DrawBtn(&Help,"Help");
settextstyle(0,0,0);
outtextxy(Close.x+7,Close.y+7,"x");
Comments();
Show();
//正如下面所示可以激活和取消激活一个菜单项
//下面的'save as'被取消激活
File.Active[3]=NO;//Save as
Edit.Active[0]=NO;//取消激活
while(1)
{
if(kbhit())
{
KEY=getch();
//如果按下"Esc"或者"-"退出程序
if(KEY==27 ? ?KEY==45) break;
}
Status();
//如果按鼠标左键
if(button==1)
{
//单击Close
if(MouseOn(&Close)) break;
//单击File
if(MouseOn(&File))
{
PullMenuDown(fm,5,&File);//菜单项为5
if(Selection==NONE) Msg("NO Selection!");
else
Msg("fm[Selection]");
if(Selection==4) break;
}
//单击Edit
if(MouseOn(&Edit))
{
PullMenuDown(em,6,&Edit);//菜单项为6
if(Selection==NONE) Msg("NO Selection!");
else
Msg("em[Selection]");
}
if(MouseOn(&Edit))
{
PullMenuDown(hm,2,&Help);//菜单项为2
if(Selection==NONE) Msg("NO Selection!");
else
Msg("hm[Selection]");
if(Selection==1) Msg("*Programming By NEERAJ SHARMA*");
}
}
else
{
//鼠标在哪个菜单项上,就高亮显示它
//高亮显示文件菜单项
if(MouseOn(&File)) Hlight(&File);
//高亮显示编辑菜单项
if(MouseOn(&Edit)) Hlight(&Edit);
//高亮显示帮助菜单项
if(MouseOn(&Help)) Hlight(&Help);
//高亮显示关闭菜单项
if(MouseOn(&Close)) Hlight(&Close);
if(MouseOn(&Neeraj))
{
Msg("Hello,everyone");
while(MouseOn(&Neeraj))
{
Status();
if(button!=0) break;
if(kbhit()) break;
}
Msg("");
}
}
}
Msg("::Bye Bye::");
}
void Msg(char *str)
{
printf("%s",str);
}
//绘制菜单项
void DrawBtn(struct MENU *tm,char *txt)
{
//设置绘制的颜色
setcolor(0);
//设置文本格式
settextstyle(2,0,4);
//输出txt文件
outtextxy(tm-> x+15,tm-> y+4,txt);
}
//高亮显示函数
void Hlight(struct MENU *t)
{
//高亮
winp(t,0);
//显示菜单项名称
Msg(t-> head);
//在没有输入的情况下,一直高亮
while(MouseOn(t))
{
Status();
if(button!=0) break;
if(kbhit()) break;
}
//消除高亮
setcolor(7);
Hide();
rectangle(t-> x,t-> y,t-> x1,t-> y1);
Msg("");
//重绘
Show();
}
//绘制菜单项的背景和边框
void winp(struct MENU *t,int state)
{
Hide();
//非高亮模式
if(state==1)
{
//两条暗边框线
setcolor(0);
line(t-> x,t-> y,t-> x,t-> y1);
line(t-> x,t-> y,t-> x1,t-> y);
//两条亮边框线
setcolor(15);
line(t-> x,t-> y,t-> x1,t-> y1);
line(t-> x,t-> y,t-> x1,t-> y1);
}
//高亮模式
else
{
//两条亮边框线
setcolor(15);
line(t-> x,t-> y,t-> x,t-> y1);
line(t-> x,t-> y,t-> x1,t-> y);
//两条暗边框线
setcolor(0);
line(t-> x1,t-> y,t-> x1,t-> y1);
line(t-> x,t-> y1,t-> x1,t-> y1);
}
Show();
}
//绘制一个矩形区域
void Win(int sx,int sy,int ex,int ey)
{
Hide();
//设置填充的颜色
setfillstyle(1,7);
//绘制一个区域
bar(sx,sy,ex,ey);
//两条亮边框线
setcolor(15);
line(sx,sy,sx,ey);
line(sx,sy,ex,sy);
//两条暗边框线
setcolor(0);
line(ex,sy,ex,ey);
line(sx,ey,ex,ey);
Show();
}
//弹出下拉菜单
void PullMenuDown(char *H[],int n,struct MENU *tm)
{
int i;
i=n*20;
//保存背景
Push(tm);
//隐藏鼠标光标
Hide();
//把菜单项位图读入内存,以供收回弹出项时重新绘制
getimage(tm-> x+1,tm-> y1+2,tm-> x+100,tm-> y1+i+5,p);
//重新设置这个区域
setcolor(0);
settextstyle(2,0,4);
//弹出下拉菜单项
for(i=0;i <=n;i++)
{
if(!tm-> Active[i])
{
setcolor(15);
outtextxy(tm-> x+15,tm-> y1+9+i*20,H[i]);
setcolor(0);
outtextxy(tm-> x+14,tm-> y1+8+i*20,H[i]);
}
else
outtextxy(tm-> x+14,tm-> y1+8+i*20,H[i]);
}
//现实鼠标光标
Show();
while(button==1) Status();
HandleMenu(n,tm);
}
void PullMenuUp(int n,struct MENU *tm)
{
int i;
//隐藏鼠标光标
Hide();
//把读入内容的原菜单重新绘制出来
putimage(tm-> x+1,tm-> y1+2,p,COPY_PUT);
//显示鼠标光标
Show();
Up(tm);
}
union REGS i,o;
struct SREGS ss;
//显示鼠标光标函数
void Show()
{
i.x.ax=1;
int86(0x33,&i,&o);
}
//隐藏鼠标光标函数
void Hide()
{
i.x.ax=2;
int86(0x33,&i,&o);
}
//获得鼠标状态函数
void Status()
{
i.x.ax=3;
int86(0x33,&i,&o);
button=o.x.bx;
x=o.x.cx;
y=o.x.dx;
}
----------------解决方案--------------------------------------------------------
高手不敢当主要是太多了 几百行的程序 再加上那些函数再连接一起,赶上重新做一个了(工作量太大 时间用的太多).
我说的是不是啊.
----------------解决方案--------------------------------------------------------
能不能给点建议啊
如果以后再写这么多的代码
不对了 该怎么办啊
----------------解决方案--------------------------------------------------------
把c学好了,学c++或者java啊,在c++里面用mfc不用修改就可以做一个记事本,你用c写会很麻烦,api要写好多个函数才能处理....
----------------解决方案--------------------------------------------------------
尽最大可能的写一段调试一段(尽可能做到,每一小段no Error, no Warning)
一般情况(能做到这,离目标已不遥远).
----------------解决方案--------------------------------------------------------
谢了 我知道怎么搞了
----------------解决方案--------------------------------------------------------
另浪费时间写什么记事本了,除非你是没有调用任何函数库而写出来的.
如果你是想在类库上面翻腾的话,还不如学MFC.
----------------解决方案--------------------------------------------------------
回复 9# 的帖子
能不能指点一下,那该学什么.本人目前对c最了解看了你的广告,你好强啊
能不能加你为qq好友啊
----------------解决方案--------------------------------------------------------