Translate

giovedì 5 febbraio 2015

MENU -PER QUALSIASI PROGRAMMA 'C++'

#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#define su 72
#define giu 80
void gotoxy(int x,int y);
void lista(void);
int movimento(int x,int y);
void bye(void);
int main() {


 int x=8;
 int y=5;
////////////////////// CICLO /////////////////////
 do{

 lista();
 y=movimento(x,y);

    system("cls");// pagina vuota */
//////////////////////  DESARROGIO DELLA LISTA ///////////////////////
   
 if(y==5){                              
     
  ////////////////////
  ///NUMERO 1 LISTA///
  ///////////////////
  printf("PAGINA #1\n\n"); 
 
 
 
     system("pause");    
  system("cls");                 
    }
   
   
   
    if(y==6){                                
            
     //////////////////////                               
  ///NUMERO 2 LISTA////
  /////////////////////
 
    printf("PAGINA #2\n\n");
   
   
     system("pause");                     
     system("cls");
    }
   
    ////////////////
    if(y==7)
 {
  printf("PAGINA #3\n\n");
  system("pause");
     system("cls");
 }
    if(y==8){ 
 bye();  
 Sleep(700);      /////////////////////
 exit(0);         ///EXIT PROGRAMMA////
}                    /////////////////////
}while(y!=9);

 return 0;
}

void gotoxy(int x,int y){
 HANDLE hCon;
 COORD dwPos;
 dwPos.X=x;
 dwPos.Y=y;
 hCon=GetStdHandle(STD_OUTPUT_HANDLE);
 SetConsoleCursorPosition(hCon,dwPos);
}

//print lista menu
void lista(void){
 gotoxy(20,2);printf("MENU");
 gotoxy(10,5);printf("1: PAGINA #1");
 gotoxy(10,6);printf("2: PAGINA #2");
 gotoxy(10,7);printf("3: PAGINA #3");
 gotoxy(10,8);printf("4: EXIT");
}

int movimento(int x,int y){
  bool MOVER=false;
 gotoxy(x,y);printf("%c",16);

 while (!MOVER){
  if(kbhit()){
   char digit=getch();
   gotoxy(x,y);printf(" ");
   if(digit==giu&&y<8)y++; 
   if(digit==su&&y>5)y--;  
   if(digit==13)break;    
   gotoxy(x,y);printf("%c",16);
  }
}
return y;
}

void bye(void){
   gotoxy(20,11);printf("%c%c%c%c%c%c",201,205,205,205,205,205);
   gotoxy(20,12);printf("%c     %c",186,205,205); 
   gotoxy(20,13);printf("%c      %c",186,186);
   gotoxy(20,14);printf("%c       %c",186,186);
   gotoxy(20,15);printf("%c      %c",186,186);
   gotoxy(20,16);printf("%c     %c",186,205,205);
   gotoxy(20,17);printf("%c%c%c%c%c%c",204,205,205,205,205,205);
   gotoxy(20,18);printf("%c     %c",186,205,205); 
   gotoxy(20,19);printf("%c      %c",186,186);
   gotoxy(20,20);printf("%c       %c",186,186);
   gotoxy(20,21);printf("%c      %c",186,186);
   gotoxy(20,22);printf("%c     %c",186,205,205);
   gotoxy(20,23);printf("%c%c%c%c%c%c",200,205,205,205,205,205);
  
  
  
   gotoxy(30,11);printf("%c       %c",186,186);
   gotoxy(30,12);printf("%c       %c",186,186); 
   gotoxy(30,13);printf("%c       %c",186,186);
   gotoxy(30,14);printf(" %c     %c",186,186);
   gotoxy(30,15);printf("  %c   %c",186,186);
   gotoxy(30,16);printf("   %c %c",186,186);
   gotoxy(30,17);printf("   %c%c%c",205,205);
   gotoxy(30,18);printf("    %c",186); 
   gotoxy(30,19);printf("    %c",186);
   gotoxy(30,20);printf("    %c",186);
   gotoxy(30,21);printf("    %c",186);
   gotoxy(30,22);printf("    %c",186);
   gotoxy(30,23);printf("    %c",186);
  
  
   gotoxy(40,11);printf("%c%c%c%c%c%c%c",201,205,205,205,205,205,205);
   gotoxy(40,12);printf("%c",186); 
   gotoxy(40,13);printf("%c",186);
   gotoxy(40,14);printf("%c",186);
   gotoxy(40,15);printf("%c",186);
   gotoxy(40,16);printf("%c",186);
   gotoxy(40,17);printf("%c%c%c%c%c%c",204,205,205,205,205,205);
   gotoxy(40,18);printf("%c",186); 
   gotoxy(40,19);printf("%c",186);
   gotoxy(40,20);printf("%c",186);
   gotoxy(40,21);printf("%c",186);
   gotoxy(40,22);printf("%c",186);
   gotoxy(40,23);printf("%c%c%c%c%c%c%c",200,205,205,205,205,205,205);
  
}

Nessun commento:

Posta un commento