分享
 
 
 

TC2.0下写的DOS底下图形中文菜单

王朝other·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

这是本人自编的在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[i].left,menuframe[i].top,menuframe[i].left+(strlen(menuframe[i].menuname)+2)*8,menuframe[i].top+20,diy_bkcolor,diy_color,menuframe[i].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;i<scount;i++) atop=(strcmp("-",menuframe[which].submenu[i])==0)?atop+10:atop+30;

size=imagesize(sleft,stop,((swidth>zwidth)?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[i])==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[i],0,diy_style);

else Tbutton(sleft+13,ptop,sleft+25+(menuframe[which].width)*8,ptop+22,diy_bkcolor,diy_color,menuframe[which].submenu[i],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<0) { listtopmenu();clear();break; }

}

return 0;

}

int inkey(void)

{int key;

while(bioskey(1)==0) display_time(400,getmaxy()-50,WHITE);

key=bioskey(0);

key=key&0xff?key&0xff:key>>8;

return (key);

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有