Code:
#include "Header.h"
int main()
{
int ch,x,y;
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
// First save the current color information
//get console scrren buffer info
GetConsoleScreenBufferInfo(h, &csbiInfo);
wOldColorAttrs = csbiInfo.wAttributes;
gotoxy(27,6);
cout<<"**********************"<<endl;
gotoxy(27,7);
cout<<"*";
gotoxy(48,7);
cout<<"*";
gotoxy(27,8);
cout<<"*";
gotoxy(48,8);
cout<<"*";
gotoxy(30,8);
//set the background colour of the word in to red colour
SetConsoleTextAttribute ( h, BACKGROUND_BLUE | BACKGROUND_INTENSITY );
cout << "1. Login.";
//set the background colour of the word in to original colour
SetConsoleTextAttribute ( h, wOldColorAttrs);
gotoxy(27,9);
cout<<"*";
gotoxy(48,9);
cout<<"*";
gotoxy(30,9);
cout<<"2. Register";
gotoxy(27,10);
cout<<"*";
gotoxy(48,10);
cout<<"*";
gotoxy(30, 10);
cout<<"3. Exit";
gotoxy(27,11);
cout<<"*";
gotoxy(48,11);
cout<<"*";
gotoxy(27,12);
cout<<"**********************"<<endl;
x = 30;
y = 8;
gotoxy(x,y);
//start while loop
while ( ( ch = get_code() ) != 27 )
{//start switch
switch ( ch ) {
case 256 + 72://arrow key up
Beep(1568, 200);//sound
while (y <9)//start while loop
y = y +1;//end while loop
y = y-1;
gotoxy(x,y);
if (y == 8)//start if
{
gotoxy(30, 8);
//set the background colour of the word in to red colour
SetConsoleTextAttribute ( h, BACKGROUND_BLUE | BACKGROUND_INTENSITY );
cout << "1. Login.";
gotoxy(30, 9);
//set the background colour of the word in to original colour
SetConsoleTextAttribute ( h, wOldColorAttrs);
cout<<"2. Register";
gotoxy(30, 10);
cout<<"3. Exit";
}
else if (y == 9 )
{
gotoxy(30, 9);
//set the background colour of the word in to red colour
SetConsoleTextAttribute ( h, BACKGROUND_BLUE | BACKGROUND_INTENSITY );
cout<<"2. Register";
gotoxy(30, 8);
//set the background colour of the word in to original colour
SetConsoleTextAttribute ( h, wOldColorAttrs);
cout << "1. Login.";
gotoxy(30, 10);
cout<<"3. Exit";
}
else if (y == 10)
{
gotoxy(30,10);
//set the background colour of the word in to red colour
SetConsoleTextAttribute ( h, BACKGROUND_BLUE | BACKGROUND_INTENSITY );
cout<<"3. Exit.";
gotoxy(30,8);
//set the background colour of the word in to colours colour
SetConsoleTextAttribute ( h, wOldColorAttrs);
cout << "1. Login.";
gotoxy(30, 9);
cout<<"2. Register.";
}//end if
break;
case 256 + 80://arrow key down
Beep(1568, 200);//sound
while (y >9)//start while loop
y = y -1;//end while loop
y = y+1;
gotoxy(x,y);
if (y == 8)//start if
{
gotoxy(30, 8);
//set the background colour of the word in to red colour
SetConsoleTextAttribute ( h, BACKGROUND_BLUE | BACKGROUND_INTENSITY );
cout << "1. Login.";
gotoxy(30, 9);
//set the background colour of the word in to original colour
SetConsoleTextAttribute ( h, wOldColorAttrs);
cout<<"2. Register.";
gotoxy(30, 10);
cout<<"3. Exit.";
}
else if (y == 9 )
{
gotoxy(30, 9);
//set the background colour of the word in to red colour
SetConsoleTextAttribute ( h, BACKGROUND_BLUE | BACKGROUND_INTENSITY );
cout<<"2. Register.";
gotoxy(30, 8);
//set the background colour of the word in to original colour
SetConsoleTextAttribute ( h, wOldColorAttrs);
cout << "1. Login.";
gotoxy(30, 10);
cout<<"3. Exit.";
}
else if (y == 10)
{
gotoxy(30,10);
//set the background colour of the word in to red colour
SetConsoleTextAttribute ( h, BACKGROUND_BLUE | BACKGROUND_INTENSITY );
cout<<"3. Exit.";
gotoxy(30,8);
//set the background colour of the word in to original colour
SetConsoleTextAttribute ( h, wOldColorAttrs);
cout << "1. Login.";
gotoxy(30, 9);
cout<<"2. Register.";
}//end if
break;
case 13://enter key
system("cls");//clear screen
if (y == 8)//start if
//call function Login
Login();
else if (y == 9)
//call function Regsiter
Register();
else if (y == 10)
//exit program
exit(-1);
//end if
}//end switch
}//end while
//set to old colour
SetConsoleTextAttribute ( h, wOldColorAttrs);
return 0;
}