Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- #include <stddef.h>
- #include <conio.h>
- // ФУНКЦИИ МЕНЮ
- void ViewMenu ();
- void Move ();
- void ViewSubMenu ();
- void SubMenu_off ();
- void BackLight (int x, int y);
- void BackLight_off ();
- HANDLE hOut;
- COORD coord = {0,0};
- CONSOLE_CURSOR_INFO ConCurInf;
- int hor_flag=0;
- int ver_flag=0;
- char* menu[4][5] = {
- {" List ",
- " View ",
- " Clear ",
- NULL
- },
- {" Student ",
- " Add ",
- " Delete ",
- " Edit ",
- NULL
- },
- {" Sort by ",
- " Date ",
- " Name ",
- NULL
- },
- {" Exit ",
- NULL
- },
- };
- main ()
- {
- hOut = GetStdHandle(STD_OUTPUT_HANDLE);
- ConCurInf.dwSize = 10;
- ConCurInf.bVisible = FALSE;
- SetConsoleCursorInfo(hOut,&ConCurInf);
- ViewMenu();
- getch();
- }
- // MENU*************************************************************************
- //******************************************************************************
- //******************************************************************************
- void ViewMenu ()
- {
- int i=0;
- coord.X=0;
- coord.Y=0;
- SetConsoleCursorPosition(hOut,coord);
- SetConsoleTextAttribute (hOut,0x70);
- while (i<4)
- {
- printf("%s",menu[i++][0]);
- }
- Move();
- }
- void Move ()
- {
- char key=0;
- coord.X = 60;coord.Y=0;
- SetConsoleCursorPosition (hOut,coord);
- while (key != 13)
- {
- BackLight (coord.X, coord.Y);
- ViewSubMenu ();
- key = getch();
- switch (key)
- {
- case 0x4d: if (coord.X==60) break;
- coord.X += 20;
- coord.Y =0;
- SetConsoleCursorPosition (hOut, coord); break;
- case 0x4b: if (coord.X==0) break;
- coord.X -= 20;
- coord.Y =0;
- SetConsoleCursorPosition (hOut, coord); break;
- case 0x48: if (coord.Y==0) break;
- coord.Y --;
- SetConsoleCursorPosition (hOut, coord); break;
- case 0x50: if (coord.X == 0)
- if (coord.Y == 2) break;
- if (coord.X == 20)
- if (coord.Y == 3) break;
- if (coord.X == 40)
- if (coord.Y == 2) break;
- if (coord.X == 60)
- if (coord.Y == 0) break;
- coord.Y ++;
- SetConsoleCursorPosition (hOut, coord); break;
- }
- }
- }
- void ViewSubMenu ()
- {
- if (coord.Y == 0)
- {
- int tmp = coord.X;
- int i=1;
- SubMenu_off ();
- SetConsoleTextAttribute (hOut, 0x70);
- coord.X = tmp;
- SetConsoleCursorPosition (hOut, coord);
- while (menu[coord.X/20][i])
- {
- coord.Y++;
- SetConsoleCursorPosition (hOut, coord);
- printf("%s",menu[coord.X/20][i++]);
- }
- coord.X = tmp;
- coord.Y = 0;
- SetConsoleCursorPosition (hOut, coord);
- hor_flag = coord.X;
- }
- }
- void SubMenu_off ()
- {
- int i=1;
- coord.X = hor_flag;
- SetConsoleCursorPosition (hOut, coord);
- SetConsoleTextAttribute (hOut, 0x00);
- while (menu[hor_flag/20][i])
- {
- coord.Y++;
- SetConsoleCursorPosition (hOut, coord);
- printf("%s",menu[hor_flag/20][i++]);
- }
- coord.X = hor_flag;
- coord.Y = 0;
- SetConsoleCursorPosition (hOut, coord);
- }
- void BackLight (int x, int y)
- {
- BackLight_off();
- int tmp=coord.X;
- SetConsoleTextAttribute (hOut, 0x31);
- printf("%s",menu[x/20][y]);
- coord.X =tmp;
- SetConsoleCursorPosition (hOut, coord);
- ver_flag = y;
- }
- void BackLight_off ()
- {
- int tmpx = coord.X;
- int tmp = coord.Y;
- SetConsoleTextAttribute (hOut, 0x70);
- coord.X = hor_flag;
- coord.Y = ver_flag;
- SetConsoleCursorPosition (hOut, coord);
- printf("%s",menu[coord.X/20][coord.Y]);
- coord.X = tmpx; coord.Y = tmp;
- SetConsoleCursorPosition (hOut, coord);
- }
Add Comment
Please, Sign In to add comment