中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » 转贴:TC2.0下写的DOS图形中文菜单
作者:
标题: 转贴:TC2.0下写的DOS图形中文菜单 上一主题 | 下一主题
mys
元老会员




积分 5170
发帖 1637
注册 2002-10-16
来自 广东佛山
状态 离线
『楼 主』:  转贴:TC2.0下写的DOS图形中文菜单

TC2.0下写的DOS图形中文菜单
这是仅有的一条留言  
View: Original Format
网上论坛:cn.comp.lang.c, cn.fan
日期:2002-07-21 10:56:58 PST


这是本人自编的在DOS下的比较全面操作的图形中文菜单!不过当前目录需要有UCDOS自带的几个字库文件!hzk24h,hzk24k文件

/*---------------------------------------------------------------------------
File: MENU.C
Function: Operate MainMenu
---------------------------------------------------------------------------*/
# define MAX_FRAME 4
# define UP 72
# define DOWN 80
# define LEFT 75
# define RIGHT 77
# define ESC 27
# define F1 59
# define DEL 83
# define SPACE 32
# define ENTER 13
# define Alt_X 45
# define Alt_Y 21
# define Alt_D 32
# define Alt_T 20
# define Alt_O 24
# define BackSpace 8
struct gmenu{
int left,top;
char *menuname;
char *submenu[7];
int count,width;
}menuframe[MAX_FRAME]={
{15,31,"数据库操作(D)",{"打开库文件",
"显示库结构",
"显示记录内容",
"记录查找",
"关闭库文件",
"-",
"退出ALT+X"},7,14,},
{175,31,"函数曲线图(T)",{"SIN函数",
"COS函数",
"TAN函数",
"CTG函数",
"-",
"B组设计"},6,12,},
{335,31,"软件(DIY)",{"窗口颜色",
"窗口字体颜色",
"主菜单设置",
"子菜单设置",
"-",
"系统填充模式",
"用户定义模式",},7,12,},
{480,31,"其他(O)",{"老鼠闯迷宫 ",
"串口通讯传输",
"音乐欣赏  ",
"-",
"系统还原",
"帮助  F1",
"关于"},7,12,}};
char *title="C语言程序综合设计";
int
diy_style=1,diy_ufill=-1,diy_color=BLUE,diy_bkcolor=LIGHTGRAY,chang=0;
int
diy_sgkcolor=RED,diy_sgcolor=WHITE,diy_mgkcolor=CYAN,diy_mgcolor=BLUE;

int setmenu(void)
{ int title_x=200;
setbkcolor(BLUE);
setcolor(WHITE);
Tbox(2,2,getmaxx()-2,getmaxy()-2,LIGHTGRAY,BLUE,4);
dis_hz(title_x,8,title,YELLOW);
Tline(6,getmaxy()-32,getmaxx()-6,getmaxy()-32);
setfillstyle(0,1);bar(10,getmaxy()-28,getmaxx()-10,getmaxy()-7);
dis_hz(10,getmaxy()-28,"操作导航:请选择………",WHITE);
dis_hz(getmaxx()-12-7*16,getmaxy()-28,"退出ALT+X",WHITE);
listtopmenu();return 0;
}
int listtopmenu(void)
{ int i;
Tbutton(7,28,getmaxx()-8,53,diy_bkcolor,diy_color,NULL,0,diy_style);
for (i=0;i<MAX_FRAME;i++)
Tbutton(menuframe.left,menuframe.top,menuframe.left+(strlen(menuframe.menuname)+2)*8,menuframe.top+20,diy_bkcolor,diy_color,menuframe.menuname,0,diy_style);
return 0;
}
int loadmenu(int which)
{int i,keylr,size,sleft,stop,zwidth,swidth,scount,atop,ptop,subwhich;
void *buffer;
subwhich=keylr=sleft=stop=0;
while (1)
{setfillstyle(0,1);bar(90,getmaxy()-28,getmaxx()-8*16,getmaxy()-7);
dis_hz(90,getmaxy()-28,menuframe[which].submenu[subwhich],WHITE);
sleft=menuframe[which].left;stop=menuframe[which].top;
zwidth=sleft+(strlen(menuframe[which].menuname)+2)*8;
swidth=sleft+(menuframe[which].width+2)*8+10;
scount=menuframe[which].count;atop=stop+30;
for (i=0;izwidth)?swidth:zwidth)+(which==2?2:12),atop+stop);
if (size!=-1) buffer=malloc(size);
if (keylr==0||change==2||(buffer&&(keylr==LEFT||keylr==RIGHT)))
{
getimage(sleft,stop,((swidth>zwidth)?swidth:zwidth)+(which==2?2:12),atop+stop,buffer);change=0;
}
Tbutton(sleft,stop,zwidth,stop+19,diy_mgkcolor,diy_mgcolor,menuframe[which].menuname,0,diy_style);
Tbutton(sleft+4,stop+30,swidth+7,atop+15,diy_bkcolor,diy_color,NULL,0,diy_style);
ptop=stop+40;
for (i=0;i<scount;i++)
{ if (strcmp("-",menuframe[which].submenu)==0)
{ Tline(sleft+8,ptop+3,swidth+5,ptop+3); ptop+=10;}
else
{ if (subwhich==i)
Tbutton(sleft+13,ptop,sleft+25+(menuframe[which].width)*8,ptop+22,diy_sgkcolor,diy_sgcolor,menuframe[which].submenu,0,diy_style);
else
Tbutton(sleft+13,ptop,sleft+25+(menuframe[which].width)*8,ptop+22,diy_bkcolor,diy_color,menuframe[which].submenu,0,diy_style);
ptop+=30; }
}
switch (keylr=inkey())
{ case Alt_X: quit();break;
case F1 : help();break;
case ESC: which=-1;break;
case LEFT:
which=which==0?MAX_FRAME-1:which-1;subwhich=0;listtopmenu();break;
case RIGHT:
which=which==MAX_FRAME-1?0:which+1;subwhich=0;listtopmenu();break;
case UP: subwhich=(subwhich==0)?scount-1:subwhich-1;
if (strcmp(menuframe[which].submenu[subwhich],"-"==0)
subwhich--;break;
case DOWN: subwhich=(subwhich==scount-1)?0:subwhich+1;
if (strcmp(menuframe[which].submenu[subwhich],"-"==0)
subwhich++;break;
case ENTER:
clear();
if (which==0)
{ if (subwhich==0) openfile();
if (subwhich==1) list_db_structure();
if (subwhich==2) list_db_recorder();
if (subwhich==3) db_search();
if (subwhich==4) closefile();
if (subwhich==6) quit();
}
if (which==1)
if (subwhich==5) {system("fpk";cleardevice();setmenu();}
else draw(subwhich+1);
if (which==2)
{ if (subwhich==0) set_bkcolor();
if (subwhich==1) set_color();
if (subwhich==2) set_mcolor();
if (subwhich==3) set_scolor();
if (subwhich==5) set_fillstyle();
if (subwhich==6) set_filluser();
}
if (which==3)
{ if (subwhich==0) {system("maze";cleardevice();setmenu();}
if (subwhich==1) message(menuframe[which].submenu[subwhich]);
if (subwhich==2) playmusic();
if (subwhich==4) reset();
if (subwhich==5) help();
if (subwhich==6) welcome();
} clear();
}
if (buffer&&(keylr==LEFT||keylr==RIGHT))
{putimage(sleft,stop,buffer,COPY_PUT);clear();}
free(buffer);
if (change==1) {listtopmenu();clear();change=2;}
if (which>8;
return (key);
}


--
            _     _
             \   /           爱吃豆儿的小虫子
,,,,,,,,,, ( @ @)     icq:128660888   OICQ:981348
(__(__(__(_) ( ^ )     E-mail:guohaicn@hotmail.com
^ ^  ^  ^ ^   ~
欢迎订阅《中国新闻组联盟》
news://news.bugnews.dns2go.com/虫网.关于杂志
http://www.cn99.com/cgi-bin/getlsts?listname=newsgroup

欢迎光临 news://news.cn99.com/cn.fan
中国fans的新闻组,中国fans的家......




我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
2003-11-12 00:00
查看资料  发送邮件  访问主页  发短消息 网志  OICQ (2664429)  编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: