1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
int menu ( char tab[][20]){
int i,max=3,pos=15,m=20,anci,touche;
clrscr() ; textcolor(GREEN);
_setcursortype(_NOCURSOR);
for (i=0;i<max;i++){
gotoxy(m+1,pos+i*2);
cprintf("%s\n",tab[i]);
}
do {
textcolor(10);// fait en sorte que le texte selectionner soit en vert claire
//petit cadre ----------------------------------------------------------------------------------------------------------------------------------------------------
gotoxy(m,pos+i*2-1) ;printf("%c",201);
for(int k=0;k<10;k++)
{
printf("%c",205);
}
printf("%c",187);
gotoxy(m,pos+i*2);printf("%c",186);
gotoxy(m+11,pos+i*2);printf("%c",186);
gotoxy(m,pos+i*2+1);printf("%c",200);
for(int k=0;k<10;k++)
{
printf("%c",205);
}
printf("%c",188);
// petit cadre -------------------------------------------------------------------------------------------------------------------------------------------------------
gotoxy(m+1,pos+i*2);
highvideo();cprintf("%s",tab[i]);
normvideo();
touche=getch();
if(touche==224)
{
textcolor(GREEN);
touche=getch();
anci=i;
if(touche==KEYDOWN)i=++i%max;
if(touche==KEYUP)i=(--i+max)%max;
gotoxy(m+1,pos+anci*2);
cprintf("%s",tab[anci]);
}
gotoxy(m,pos+anci*2-1) ;printf(" ");
for(int k=0;k<10;k++)
{
printf(" ");
}
printf(" ");
gotoxy(m,pos+anci*2);printf(" ");
gotoxy(m+11,pos+anci*2);printf(" ");
gotoxy(m,pos+anci*2+1);printf(" ");
for(int k=0;k<10;k++)
{
printf(" ");
}
printf(" ");
Beep(900,70);
}while(touche != 13);
return(i);
} |
Partager