C语言做界面。

作者在 2010-06-16 22:24:16 发布以下内容
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"dos.h"
#include"conio.h"
#include"bios.h"

#define UP 18432
#define DOWN 20480
#define ENTER 7181

static int Current_highlight_counter = 0;

struct contact
{
    char name[15];
    char phonenumber[16];
    char homenumber[16];
}Contactlist[10];


void Get_initial_value()
{
    strcpy(Contactlist[0].name,"Aarhus");
    strcpy(Contactlist[0].phonenumber,"03812344321");
    strcpy(Contactlist[0].homenumber,"01012344321");
    strcpy(Contactlist[1].name,"Agenda");
    strcpy(Contactlist[1].phonenumber,"13812344321");
    strcpy(Contactlist[1].homenumber,"01012344321");
    strcpy(Contactlist[2].name,"Blankman");
    strcpy(Contactlist[2].phonenumber,"23812344321");
    strcpy(Contactlist[2].homenumber,"01012344321");
    strcpy(Contactlist[3].name,"Coolgirl");
    strcpy(Contactlist[3].phonenumber,"33812344321");
    strcpy(Contactlist[3].homenumber,"01012344321");
    strcpy(Contactlist[4].name,"Daffodil");
    strcpy(Contactlist[4].phonenumber,"43812344321");
    strcpy(Contactlist[4].homenumber,"01012344321");
    strcpy(Contactlist[5].name,"Earl");
    strcpy(Contactlist[5].phonenumber,"53812344321");
    strcpy(Contactlist[5].homenumber,"01012344321");
    strcpy(Contactlist[6].name,"Flying");
    strcpy(Contactlist[6].phonenumber,"63812344321");
    strcpy(Contactlist[6].homenumber,"01012344321");
    strcpy(Contactlist[7].name,"Gabriel");
    strcpy(Contactlist[7].phonenumber,"73812344321");
    strcpy(Contactlist[7].homenumber,"01012344321");
    strcpy(Contactlist[8].name,"Handsome");
    strcpy(Contactlist[8].phonenumber,"83812344321");
    strcpy(Contactlist[8].homenumber,"01012344321");
    strcpy(Contactlist[9].name,"Iceland");
    strcpy(Contactlist[9].phonenumber,"93812344321");
    strcpy(Contactlist[9].homenumber,"01012344321");
}

void Menu()
{
    char *s = "           Phonebook";
    Get_initial_value();
    system("cls");
    textmode(C40);
    window(1,1,26,1);
    textbackground(0);
    textcolor(YELLOW);
    cputs(s);
    window(1,2,40,20);
    textbackground(BLUE);
    textcolor(GREEN);
    clrscr();
    printf("%s\n",Contactlist[0].name);
    printf("%s\n",Contactlist[1].name);
    printf("%s\n",Contactlist[2].name);
    printf("%s\n",Contactlist[3].name);
    printf("%s\n",Contactlist[4].name);
    printf("%s\n",Contactlist[5].name);
    printf("%s\n",Contactlist[6].name);
    printf("%s\n",Contactlist[7].name);
    printf("%s\n",Contactlist[8].name);
    printf("%s\n",Contactlist[9].name);

}

void Buffer()
{
    window(1,1+Current_highlight_counter,10,1.5+Current_highlight_counter);
    textbackground(BLUE);
    clrscr();
    textcolor(GREEN);
    cputs(&Contactlist[Current_highlight_counter-1]);
    window(1,1.5+Current_highlight_counter,10,2+Current_highlight_counter);
    textbackground(RED);
    clrscr();
    textcolor(0);
    cputs(&Contactlist[Current_highlight_counter]);

}


void Highlight_change()
{
    int key;
    window(1,2,40,2.5);
    textbackground(RED);
    textcolor(0);
    cputs(&Contactlist[0]);
    while(1)
    {
        key = bioskey(0);/*获取键盘码*/
        if (key == UP) Current_highlight_counter--;
        if (key == DOWN) Current_highlight_counter++;
        Current_highlight_counter = Current_highlight_counter % 10;
        Buffer();
    }

}


main()
{
    Menu();
    Highlight_change();
    getchar();
}
      记得之前在网上找着过一个西文下拉菜单的代码,里边有个函数,大概是叫buff,是记录点一个菜单后盖住的区域,然后当释放这个菜单的时候再把这一块区域的东西打印出来,现在写一个通迅录,需要有highlight 功能,但是highlight的item滚动后,之前highlight的一条颜色却没能释放,希望谁可以帮忙解决一下这个问题。谢谢了。用的编译器是WIN-TC.
默认分类 | 阅读 785 次
文章评论,共0条
游客请输入验证码
文章分类
文章归档
最新评论