| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 902 人关注过本帖
标题:C语言扫描码的问题?
只看楼主 加入收藏
no_did
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-12-28
收藏
 问题点数:0 回复次数:0 
C语言扫描码的问题?
/* Note:Your choice is C IDE */
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <dos.h>
#include <conio.h>
/* define Keys scan code */ /* 定义各键的扫描码 */
#define Key_DOWN 80
#define Key_UP 72
#define Key_A 30
#define Key_B 48
#define Key_C 46
#define Key_Q 18
#define Key_ENTER 28

int key();

main()
{
int ky,y;
char ch;
textbackground(0);
clrscr();
do
{
textmode(C80);
textbackground(13);
textcolor(RED);
window(7,8,19,15);
clrscr();
textbackground(1);
textcolor(RED);
window(8,9,18,14);
clrscr();
gotoxy(3,3);
cprintf("Q:quit\r\n");
gotoxy(3,4);
cprintf("A:dir\r\n");
gotoxy(3,5);
cprintf("B:dir/p\r\n");
gotoxy(3,6);
cprintf("C:dir/w\r\n");
y=10;
upbar(y-1);
do
{
ky=key();
switch(ky)
{
case Key_A:
{
y=12,
ky=Key_ENTER;
};
break;
case Key_B:
{
y=13,
ky=Key_ENTER;
};
break;
case Key_C:
{
y=14,
ky=Key_ENTER;
};
break;
case Key_Q:
{
y=11,
ky=Key_ENTER;
};
break;
case Key_DOWN:
if(y<13)
{
upbar(y);
y++;
};
break;
case Key_UP:
if(y>10)
{
downbar(y);
y--;
};
break;
}
}while(ky!=Key_ENTER);
textcolor(WHITE);
switch(y)
{
case 11:
ch='%';
break;
case 12:
{
systen("dir");
getch();
};
break;
case 13:
{
systen("dir/p");
getch();
};
break;
case 14:
{
systen("dir/w");
getch();
};
break;
} ;
if(ch=='%')
break;
}while(1);
clrscr();
}

int key()
{
union REGS rg;
rg.h.ah=0;
int86(0x16,&rg,&rg);
return rg.h.ah;
}

upbar(int y)
{
int i;
typedef struct texel_struct
{
unsigned char ch;
unsigned char attr;
}texel;
texel t;
for(i=9;i<=17;i++)
{
gettext(i,y,i,y,&t);
t.attr=0x1f;
puttext(i,y,i,y,&t);
gettext(i,y+1,i,y+1,&t);
t.attr=0x4f;
puttext(i,y+1,i,y+1,&t);
};
gotoxy(3,y+1);
return;
}

downbar(int y)
{
int i;
typedef struct texel_struct
{
unsigned char ch;
unsigned char attr;
}texel;
texel t;
for(i=9;i<=17;i++)
{
gettext(i,y,i,y,&t);
t.attr=0x1f;
puttext(i,y,i,y,&t);
gettext(i,y-1,i,y-1,&t);
t.attr=0x4f;
puttext(i,y-1,i,y-1,&t);
};
gotoxy(3,y+1);
return;
}
各位大虾能帮我看看以上程序中/* define Keys scan code */ /* 定义各键的扫描码 */ 下面定义各键的扫描码是什么意思吗?还有swich语句里y=12等等是什么意思为什么啊?为什么其他书上或网上的扫描码和它的不一样啊,是不是扫描码是可以自己定的啊?最好有高手帮我解释一下此段程序中的全部意思,越详细越好,非常感谢!急!急!急!
搜索更多相关主题的帖子: C语言 define Key include 扫描 
2007-12-28 00:29
快速回复:C语言扫描码的问题?
数据加载中...
 
   



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

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