| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 265 人关注过本帖
标题:错哪了?
只看楼主 加入收藏
龙龙爱着徐琼
Rank: 1
来 自:石家庄
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-7-6
收藏
 问题点数:0 回复次数:2 
错哪了?
在 TC2.0下运行,可是功能不能实现啊!

#include <stdio.h>
#include <conio.h>
#include <bios.h>

#define NULL 0
typedef struct menu
{
    int ID;
    int x;
    int y;
    int active;
    char content[20];
    struct menu *pSubMenu;
    int n_SubMenu;
}MENU;
#define FILE 1
#define EDIT 2
#define SORT 3
#define FILTER 4
#define HELP 5
#define FILE_NEW 11
#define FILE_OPEN 12
#define FILE_SAVE 13
#define FILE_SAVEAS 14
#define FILE_CLOSE 15
#define FILE_EXIT 16
#define EDIT_ADD 21
#define EDIT_DEL 22
#define EDIT_MOD 23
#define SORT_NUM 31
#define SORT_NAME 32
#define FILTER_NUM 41
#define FILTER_NAME 42
#define FILTER_NEW 43
#define HELP_HELP 51
#define HELP_ABOUT 52
MENU FileSub[6]={
        {FILE_NEW,1,2,1,"New",NULL,0},
        {FILE_OPEN,1,3,0,"Open",NULL,0},
        {FILE_SAVE,1,4,0,"Save",NULL,0},
        {FILE_SAVEAS,1,5,0,"Save As",NULL,0},
        {FILE_CLOSE,1,6,0,"Close",NULL,0},
        {FILE_EXIT,1,7,0,"Exit",NULL,0}
        };
MENU EditSub[3]={
        {EDIT_ADD,15,2,1,"Add",NULL,0},
        {EDIT_DEL,15,3,0,"Delete",NULL,0},
        {EDIT_MOD,15,4,0,"Modify",NULL,0}
        };
MENU SortSub[2]={
        {SORT_NUM,30,2,1,"Number",NULL,0},
        {SORT_NAME,30,3,0,"Name",NULL,0}
        };
MENU FilterSub[3]={
        {FILTER_NUM,45,2,1,"Number",NULL,0},
        {FILTER_NAME,45,3,0,"Name",NULL,0},
        {FILTER_NEW,45,4,0,"New",NULL,0}
        };
MENU HelpSub[2]={
        {HELP_HELP,60,2,1,"Help",NULL,0},
        {HELP_ABOUT,60,3,0,"About",NULL,0}
        };
MENU MainMenu[5]={
        {FILE,1,1,0,"File",FileSub,6},
        {EDIT,15,1,0,"Edit",EditSub,3},
        {SORT,30,1,0,"Sort",SortSub,2},
        {FILTER,45,1,0,"Fileter",FilterSub,3},
        {HELP,60,1,0,"Help",HelpSub,2}
        };
void MenuDraw(MENU *pMenu,int n)
{
    window(1,1,80,25);
    for(;n>0;n--)
    {
        textbackground(pMenu->active?BLUE:WHITE);
        textcolor(RED);
        gotoxy(pMenu->x,pMenu->y);
        cprintf("%s",pMenu->content);
        pMenu++;
    }
}
void FrameDraw()
{
    int i,j;
    textbackground(BLACK);
    clrscr();
    window(1,1,80,25);
    textbackground(WHITE);
    clrscr();
    window(1,25,80,25);
    clrscr();
    textbackground(CYAN);
    textcolor(BLACK);
    window(1,2,80,2);
    clrscr();
    window(1,24,80,24);
    clrscr();
    window(1,2,1,24);
    clrscr();
    window(80,2,80,24);
    clrscr();

    window(1,1,80,25);
    for(i=2;i<80;i++)
    {
        gotoxy(i,2);
        cprintf("%c",205);
        gotoxy(i,24);
        cprintf("%c",205);
    }
    for(j=3;j<24;j++)
    {
        gotoxy(1,j);
        cprintf("%c",186);
        gotoxy(80,j);
        cprintf("%c",186);
    }
    gotoxy(1,2);cprintf("%c",201);
    gotoxy(80,2);cprintf("%c",187);
    gotoxy(1,24);cprintf("%c",200);
    gotoxy(80,24);cprintf("%c",188);
    textbackground(WHITE);
    window(2,3,4,23);
    clrscr();
    textbackground(BLACK);
    window(5,3,54,23);
    clrscr();
    textbackground(YELLOW);
    window(56,3,79,12);
    clrscr();
    textbackground(BLUE);
    window(56,14,79,23);
    clrscr();
    window(1,1,80,25);
    textcolor(BLACK);
    textbackground(CYAN);
    for(j=3;j<24;j++)
    {
        gotoxy(55,j);
        cprintf("%c",186);
    }
    for(i=56;i<80;i++)
    {
        gotoxy(i,13);
        cprintf("%c",205);
    }
    gotoxy(55,2);cprintf("%c",203);
    gotoxy(55,24);cprintf("%c",202);
    gotoxy(55,13);cprintf("%c",204);
    gotoxy(80,13);cprintf("%c",185);
    
    gotoxy(21,2);cprintf("Student List");
    gotoxy(60,2);cprintf("Filter Information");
    gotoxy(60,13);cprintf("Input Information");

    gotoxy(4,3);cprintf("No.");
    gotoxy(14,3);cprintf("Name");
    gotoxy(30,3);cprintf("Age");
    gotoxy(35,3);cprintf("Address");

    MenuDraw(MainMenu,5);
}

#define UP_KEY 0x4800
#define DOWN_KEY 0x5000
#define LEFT_KEY 0x4b00
#define RIGHT_KEY 0x4d00
#define F10_KEY 0x4400
#define RETURN_KEY 0x1c0d
#define BS_KEY 0x0e08
#define ESC_KEY 0x011b
int MenuSelect()
{
    int b_Exit=0;
    int result=0;
    int b_SubMenu=0;
    int left=1,top=1,right=1,bottom=1,n;
    char buffer[500];
    MainMenu[0].active=1;
    MenuDraw(MainMenu,5);
    while(!b_Exit)
    {
        switch(bioskey(0))
        {
            case F10_KEY:
            if(b_SubMenu)
            {
                b_SubMenu=0;
                puttext(left,top,right,bottom,buffer);
            }break;
            case ESC_KEY:
            n=SearchActiveMenu(MainMenu,5);
            MainMenu[n].active=0;
            if(b_SubMenu)
            {
                puttext(left,top,right,bottom,buffer);
            }
            MenuDraw(MainMenu,5);result=0;b_Exit=1;break;
            case UP_KEY:
            if(b_SubMenu)
            {
                int m;
                n=SearchActiveMenu(MainMenu,5);
                m=SearchActiveMenu(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
                (MainMenu[n].pSubMenu+m)->active=0;
                if(m==0)
                {
                    (MainMenu[n].pSubMenu+MainMenu[n].n_SubMenu-1)->active=1;
                }
                else
                {
                    (MainMenu[n].pSubMenu+m-1)->active=1;
                }
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }break;
            case DOWN_KEY:
            if(b_SubMenu)
            {
                int m;n=SearchActiveMenu(MainMenu,5);
                m=SearchActiveMenu(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
                (MainMenu[n].pSubMenu+m)->active=0;
                if(m==(MainMenu[n].n_SubMenu-1))
                {
                    MainMenu[n].pSubMenu->active=1;
                }
                else
                {
                    (MainMenu[n].pSubMenu+m+1)->active=1;
                }
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }break;    
            case LEFT_KEY:
            n=SearchActiveMenu(MainMenu,5);
            MainMenu[n].active=0;
            n=(n==0)?4:(n-1);
            MainMenu[n].active=1;
            MenuDraw(MainMenu,5);
            if(b_SubMenu)
            {
                puttext(left,top,right,bottom,buffer);
                left=MainMenu[n].pSubMenu->x;
                top=2;
                right=left+20;
                bottom=top+MainMenu[n].n_SubMenu-1;
                gettext(left,top,right,bottom,buffer);
                window(left,top,right,bottom);
                textbackground(WHITE);
                clrscr();
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }break;
            case RIGHT_KEY:
            n=SearchActiveMenu(MainMenu,5);
            MainMenu[n].active=0;
            n=(n+1)%5;
            MainMenu[n].active=1;
            MenuDraw(MainMenu,5);
            if(b_SubMenu)
            {
                puttext(left,top,right,bottom,buffer);
                left=MainMenu[n].pSubMenu->x;
                top=2;right=left+20;
                bottom=top+MainMenu[n].n_SubMenu-1;
                gettext(left,top,right,bottom,buffer);
                window(left,top,right,bottom);
                textbackground(WHITE);
                clrscr();
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }break;
            case RETURN_KEY:
            n=SearchActiveMenu(MainMenu,5);
            if(!b_SubMenu)
            {
                b_SubMenu=1;
                left=MainMenu[n].pSubMenu->x;
                top=2;right=left+20;
                bottom=top+MainMenu[n].n_SubMenu-1;
                gettext(left,top,right,bottom,buffer);
                window(left,top,right,bottom);
                textbackground(WHITE);
                clrscr();
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }
            else
            {
                int m;
                m=SearchActiveMenu(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
                result=(MainMenu[n].pSubMenu+m)->ID;
                MainMenu[n].active=0;
                puttext(left,top,right,bottom,buffer);
                MenuDraw(MainMenu,5);
                b_Exit=1;
            }
        }break;
    }return(result);

}
int SearchActiveMenu(MENU *pMenu,int n)
{
    for(n--;n>=0;n--)
    {
        if(pMenu[n].active) break;
    }return(n);
}




main()
{    
    int b_Exit=0;
    /*textmod(C80);*/
    textbackground(BLACK);
    textcolor(WHITE);
    clrscr();
    FrameDraw();

    while(!b_Exit)
    {
        switch(bioskey(0))
        {
            case F10_KEY:
            if(MenuSelect()==FILE_EXIT)
            b_Exit=1;
            case UP_KEY:
            case DOWN_KEY:break;
        }
    }
}
搜索更多相关主题的帖子: 什么是 标签 
2008-07-06 20:43
很远的那颗星
Rank: 2
等 级:新手上路
威 望:4
帖 子:544
专家分:0
注 册:2008-6-30
收藏
得分:0 
楼主发对地方啦,支持楼主.

Fighting~~~~~~~~
2008-07-06 20:59
jxyga111
Rank: 8Rank: 8
来 自:中華人民共和國
等 级:贵宾
威 望:33
帖 子:6015
专家分:895
注 册:2008-3-21
收藏
得分:0 
LZ沒看到版塊的名字啊

烈焰照耀世界,斌凍凍千萬裏
2008-07-07 08:50
快速回复:错哪了?
数据加载中...
 
   



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

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