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
|
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
#define KEY_UP 72
#define KEY_DOWN 80
#define KEY_ENTER 13
#define ARRAYSIZE(sel) (sizeof(sel) / sizeof(sel[0]))
/** SELECT_END is the last highlighted choice in selections. */
#define SELECT_END 12
void clear();
void menu();
void selector(unsigned int select);
void hideCursor();
int main()
{
hideCursor();
menu();
return 0;
}
void hideCursor()
{
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO info;
info.dwSize = 100;
info.bVisible = FALSE;
SetConsoleCursorInfo(consoleHandle, &info);
}
void menu()
{
int select = 0;
int x;
selector(select);
while(x = getch())
{
if(x == 72)
{
select -= 2;
if(select < 0)
select = 0;
selector(select);
}
else if(x == 80)
{
select += 2;
if (select > SELECT_END)
select = SELECT_END;
selector(select);
}
}
}
void clear()
{
system("cls");
}
void selector(unsigned int select)
{
const char *selections[] =
{
"\n\n\n\n\n\t 1. Input info <",
"\n\n\n\n\n\t 1. Input info",
"\t 2. Retrieve info <",
"\t 2. Retrieve info",
"\t 3. Modify info <",
"\t 3. Modify info",
"\t 4. View info list <",
"\t 4. View info list",
"\t 5. Delete info <",
"\t 5. Delete info",
"\t 6. About the program <",
"\t 6. About the program",
"\t 7. Exit Data Base <",
"\t 7. Exit Data Base",
};
unsigned int i;
clear();
for(i = 0; i < ARRAYSIZE(selections); i += 2)
{
if(i == select)
printf ("%s\n", selections[i]);
else
printf ("%s\n", selections[i + 1]);
}
}
|