主题:超级菜鸟求问~如何在这个电子琴程序中实现鼠标使用?
#include <graphics.h>
#include <stdio.h>
void my_delay(int clicks)
{
unsigned int far *clock=(unsigned int far *)0x0000046CL;
unsigned int now;
now=*clock;
while(abs(*clock-now)<clicks){}
}
wenzixianshi()
{
int x,y,i;
char ch[2];
char str[]="1234567qwertyuasdfghj";
x=100;
setcolor(BLUE);
settextstyle(4,0,8);
outtextxy(90,10,"The C Piano");
settextstyle(0,0,2);
outtextxy(90,100,"Please use A-U to make sound");
settextstyle(0,0,1);
outtextxy(120,320,"Press ESC to exit.");
setcolor(RED);
for(i=0;i<21;i++)
{
ch[0]=str[i];
ch[1]=0;
outtextxy(x+5,160,ch);
x+=20;
}
}
donghua()
{
int i,j,x,stepx=100,stepy=180;
char ch,str[2];
unsigned int fre;
wenzixianshi();
while(1){
setcolor(BLUE);
for(i=0;i<21;i++)
{
rectangle(stepx+i*20,stepy+0,stepx+i*20+20,stepy+100);
}
ch=bioskey(0);
if(ch==27)
break;
/*frq[3][7]={262,294,330,349,392,440,494,
524,587,659,698,784,880,988,
1024,1174,1318,1396,1568,1760,1976}; */
switch(ch)
{
case'1':i=0;j=262;break;
case'2':i=1;j=294;break;
case'3':i=2;j=330;break;
case'4':i=3;j=349;break;
case'5':i=4;j=392;break;
case'6':i=5;j=440;break;
case'7':i=6;j=494;break;
case'q':i=7;j=524;break;
case'w':i=8;j=587;break;
case'e':i=9;j=659;break;
case'r':i=10;j=698;break;
case't':i=11;j=784;break;
case'y':i=12;j=880;break;
case'u':i=13;j=988;break;
case'a':i=14;j=1024;break;
case's':i=15;j=1174;break;
case'd':i=16;j=1318;break;
case'f':i=17;j=1396;break;
case'g':i=18;j=1568;break;
case'h':i=19;j=1760;break;
case'j':i=20;j=1976;break;
default :continue;
}
setfillstyle(1,15);
bar(stepx+i*20,stepy+0,stepx+i*20+20,stepy+100);
sound(j);
my_delay(3);
nosound();
setfillstyle(1,0);
bar(stepx+i*20,stepy+0,stepx+i*20+20,stepy+100);
}
}
main()
{
int mode;
int driver=DETECT;
initgraph(&driver,&mode,"d:\\tc3\\bgi");
cleardevice();
donghua();
closegraph();
}
小妹刚刚开始真正编稍微大的程序……鼠标调用看不懂……
如果哪位高人能把鼠标调用嵌入编好~然后高亮出修改的地方~那就再感谢不过了!
#include <stdio.h>
void my_delay(int clicks)
{
unsigned int far *clock=(unsigned int far *)0x0000046CL;
unsigned int now;
now=*clock;
while(abs(*clock-now)<clicks){}
}
wenzixianshi()
{
int x,y,i;
char ch[2];
char str[]="1234567qwertyuasdfghj";
x=100;
setcolor(BLUE);
settextstyle(4,0,8);
outtextxy(90,10,"The C Piano");
settextstyle(0,0,2);
outtextxy(90,100,"Please use A-U to make sound");
settextstyle(0,0,1);
outtextxy(120,320,"Press ESC to exit.");
setcolor(RED);
for(i=0;i<21;i++)
{
ch[0]=str[i];
ch[1]=0;
outtextxy(x+5,160,ch);
x+=20;
}
}
donghua()
{
int i,j,x,stepx=100,stepy=180;
char ch,str[2];
unsigned int fre;
wenzixianshi();
while(1){
setcolor(BLUE);
for(i=0;i<21;i++)
{
rectangle(stepx+i*20,stepy+0,stepx+i*20+20,stepy+100);
}
ch=bioskey(0);
if(ch==27)
break;
/*frq[3][7]={262,294,330,349,392,440,494,
524,587,659,698,784,880,988,
1024,1174,1318,1396,1568,1760,1976}; */
switch(ch)
{
case'1':i=0;j=262;break;
case'2':i=1;j=294;break;
case'3':i=2;j=330;break;
case'4':i=3;j=349;break;
case'5':i=4;j=392;break;
case'6':i=5;j=440;break;
case'7':i=6;j=494;break;
case'q':i=7;j=524;break;
case'w':i=8;j=587;break;
case'e':i=9;j=659;break;
case'r':i=10;j=698;break;
case't':i=11;j=784;break;
case'y':i=12;j=880;break;
case'u':i=13;j=988;break;
case'a':i=14;j=1024;break;
case's':i=15;j=1174;break;
case'd':i=16;j=1318;break;
case'f':i=17;j=1396;break;
case'g':i=18;j=1568;break;
case'h':i=19;j=1760;break;
case'j':i=20;j=1976;break;
default :continue;
}
setfillstyle(1,15);
bar(stepx+i*20,stepy+0,stepx+i*20+20,stepy+100);
sound(j);
my_delay(3);
nosound();
setfillstyle(1,0);
bar(stepx+i*20,stepy+0,stepx+i*20+20,stepy+100);
}
}
main()
{
int mode;
int driver=DETECT;
initgraph(&driver,&mode,"d:\\tc3\\bgi");
cleardevice();
donghua();
closegraph();
}
小妹刚刚开始真正编稍微大的程序……鼠标调用看不懂……
如果哪位高人能把鼠标调用嵌入编好~然后高亮出修改的地方~那就再感谢不过了!