文本界面下的下拉菜单有兄弟给个例子吗

BBDD731 2005-05-09 02:51:15
1.文本界面下的下拉菜单有兄弟给个例子吗

2.如果我要用alt+x退出,怎么能知道它的10进制码是多少,是alt与x相加的结果吗?
...全文
121 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
BBDD731 2005-05-10
  • 打赏
  • 举报
回复
已经明白了,谢谢
BBDD731 2005-05-10
  • 打赏
  • 举报
回复
nKey=0;
while(bioskey(1)==0);
nKey=bioskey(0);
nKey=nKey&0xff?0: nKey>>8;
if(nKey==45) exit(0);

谢谢两位的帮忙,我就是想知道为什么上面的代码中把扫描码移到前8位后alt+x的值为45?
woundedsoul 2005-05-10
  • 打赏
  • 举报
回复
我没有TC了!
du51 2005-05-09
  • 打赏
  • 举报
回复
TC下成功.
注:不是我写的.是我一本书上的.
du51 2005-05-09
  • 打赏
  • 举报
回复

SoundSing_f();
Blound_f();
int Changedirnx_f(int);
int Changedirny_f(int );

#include<conio.h>
#include<graphics.h>
#include<alloc.h>
#include<dos.h>
SoundSing_f()/*音乐:两只老虎*/
{
unsigned naSing[]={262, 250, 294, 250, 330, 250, 262,250,
262,250,294,250,330,250,262,250,
330,250,349,250,392,500,
330,250,349,250,392,500,
392,125,440,125,392,125,349,125,330,250,262,250,
392,125,440,125,392,125,349,125,330,250,262,250,
294,250,196,250,262,500,
294,250,196,250,262,500,0,0};
unsigned int *naPoint;
naPoint=naSing;
while(*naPoint)
{
sound((*naPoint++));
delay(200*(*naPoint++));
nosound();
}
}

Blound_f(){

int gd=DETECT,gm;
int nArea,nStartx,nStarty,nMinx=0,nMaxx=630,nMiny=0,nMaxy=470,nCurx=300,nCury=30;
char *chpBuff;
int nChangeX,nChangeY,nIni=0;

initgraph(&gd,&gm,"");
cleardevice();

setcolor(3);
outtextxy(225,185,"B O U N C I N G B A L L");
setcolor(14);
outtextxy(240,220,"Programming :Aisharya");
getch();

cleardevice();
setcolor(7);
rectangle(2,2,630,479);
rectangle(3,3,629,478);
setcolor(13);
circle(7,7,3);setfillstyle(SOLID_FILL,13);floodfill(7,7,13);
nArea=imagesize(4,4,11,11);
chpBuff=malloc(nArea);
getimage(4,4,11,11,chpBuff);
setcolor(0);
circle(7,7,3);setfillstyle(SOLID_FILL,0);floodfill(7,7,0);

while(!kbhit()){
delay(200);if(nIni!=0)putimage(nStartx,nStarty,chpBuff,XOR_PUT);
nStartx=nCurx;nStarty=nCury; nIni=1;
putimage(nCurx,nCury,chpBuff,XOR_PUT);
if(nCurx>nMaxx || nCurx<nMinx)nChangeX=Changedirnx_f(nCurx);
if(nCury>nMaxy || nCury<nMiny)nChangeY=Changedirny_f(nCury);
if(nChangeX==1)nCurx++;else nCurx--;
if(nChangeY==1)nCury++;else nCury--;}
restorecrtmode();closegraph();
printf("Thank You.\n");
getch();}

Changedirnx_f(int nCurx){
int nChangeX;
if(nCurx>630)nChangeX=0;
if(nCurx<0)nChangeX=1;
sound(100);delay(80);nosound();
return(nChangeX);}

Changedirny_f(int nCury){
int nChangeY;
if(nCury>460)nChangeY=0;
if(nCury<0)nChangeY=1;
sound(100);delay(80);nosound();
return(nChangeY);}
main()
{
int nCount, nKey0,nKey,nKey1,nValue,nTest;
char *szMainMenu[]={"File","Edit", "Run","Compile",
"Project","Options","Debug","Break/watch"};
char *szSubMenu[]={"MOVEBALL ",
"SOUND ",
"New ",
"Save ",
"Write to ",
"Directory ",
"Change dir ",
"Os shell ",
"Quit Alt-X "
};
char naBuf[19*14*2], naBufOne[19*2];/*缓冲区,保存窗口大小 行×列×2*/
window(1,1,80,25);
textbackground(BLUE);
clrscr();
window(1,1,80,1);
textbackground(WHITE);
textcolor(BLACK);
clrscr();
window(1,1,80,1);
for(nCount=0;nCount<8;nCount++)/*显示主菜单*/
cprintf(" %s",szMainMenu[nCount]);
while(1)
{
nKey=0;
while(bioskey(1)==0);
nKey=bioskey(0);
nKey=nKey&0xff?0: nKey>>8;
if(nKey==45) exit(0);
if(nKey==33) /* Alt+F */
{
textbackground(BLACK);
textcolor(WHITE);
gotoxy(3,1); /*反白显示主菜单选项*/
cprintf("%s",szMainMenu[0]);
gettext(3,1,18,14,naBuf);/*第二行第三列开始,存11行16列 */
window(3,2,18,12);/*开辟窗口*/
textbackground(WHITE);
textcolor(BLACK);
clrscr();
window(3,2,18,13); /*多开辟一行,最后字符有回车符 */
gotoxy(1,1); /*画方框*/
putch(0xda);
for(nCount=2;nCount<16;nCount++)
putch(0xc4);
putch(0xbf);
for(nCount=2;nCount<11;nCount++)
{
gotoxy(1,nCount);
putch(0xb3);
gotoxy(16,nCount);
putch(0xb3);
}
gotoxy(1,11);
putch(0xc0);
for(nCount=2;nCount<16;nCount++)
putch(0xc4);
putch(0xd9);
for(nCount=1;nCount<10;nCount++)/*显示子菜单*/
{
gotoxy(2,nCount+1);
cprintf("%s",szSubMenu[nCount-1]);
}
gettext(2,2,18,3,naBufOne); /*存一行*/
textbackground(BLACK);
textcolor(WHITE);
gotoxy(2,2);
cprintf("%s",szSubMenu[0]); /*反白显示子菜单*/
nValue=2;
nKey0=0;
while(nKey0!=27&&nKey0!=45&&nKey0!=13) /* 输入为Alt+X、回车或ESC时退出*/
{
while(bioskey(1)==0);
nKey0=nKey1=bioskey(0);
nKey0=nKey0&0xff;
nKey1=nKey1&0xff?0:nKey1>>8;
if(nKey1==72||nKey1==80) /*为上下箭头键*/
{
puttext(2,nValue,18,nValue+1,naBufOne);
if(nKey1==72)nValue=(nValue==2)?10:nValue-1;
if(nKey1==80)nValue=(nValue==10)?2:nValue+1;
gettext(2,nValue,18,nValue+1,naBufOne);
textbackground(BLACK);
textcolor(WHITE);
gotoxy(2,nValue);
cprintf("%s",szSubMenu[nValue-2]);
}
nTest=nValue-1;
}
if(nKey1==45) exit(0);
if(nKey0==13)
{
switch(nValue-1)
{
case 1:
Blound_f(); /*显示运动小球*/
main();
case 2:
SoundSing_f(); /*音乐*/
main();
case 9:
exit(0);
default:
break;
}
}
else
{
window(1,1,80,1);
puttext(3,1,18,14,naBuf);
textbackground(WHITE);
textcolor(BLACK);
gotoxy(3,1);
cprintf("%s",szMainMenu[0]);
}
}
}
}
积木 2005-05-09
  • 打赏
  • 举报
回复
你要做的是windows程序么,菜单的例子就看看记事本的样子就可以了。

至于alt+x,可以在你的消息响应中处理WM_KEYDOWN 这两个消息,然后判断这两个消息附加的值,wParam和lParam,具体可以参考msn,我贴出来一部分。

wParam
Specifies the virtual-key code of the nonsystem key.

lParam
Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table.
0-15
Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
16-23
Specifies the scan code. The value depends on the OEM.
24
Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25-28
Reserved; do not use.
29
Specifies the context code. The value is always 0 for a WM_KEYDOWN message.
30
Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up.
31
Specifies the transition state. The value is always zero for a WM_KEYDOWN message.

70,037

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧