Unregistered you're right but I'm trying.
In the main function I have this:
Code:
int main()
{
HANDLE hStdout, hInput = GetStdHandle(STD_INPUT_HANDLE); //handle to input
INPUT_RECORD ir; //keyevent structure
DWORD dwRead = 0; //dummy....forget this for now
BOOL Loop = TRUE;
int x = 0;
ZeroMemory (&ir, sizeof(INPUT_RECORD)); //clear the memory before starting
while (Loop)
{
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
clrscr ();
SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN);
gotoxy (5, 1);
printf ("File\tSearch\tTools\tHelp");
if (ReadConsoleInput(hInput, &ir, 1, &dwRead) //read input
&& ir.EventType == KEY_EVENT //is it a key?
&& ir.Event.KeyEvent.bKeyDown)
{//Is the key down or up?
switch (ir.Event.KeyEvent.wVirtualKeyCode)
{//What was the key?
case VK_RIGHT:
x += 10;
SetConsoleTextAttribute (hStdout, FOREGROUND_INTENSITY | BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
gotoxy (x + 5, 1);
printf ("Search");
/*if (getch() == 13)
{
gotoxy (18, 3);
printf("BLAH!");
getch();
}*/
if (x == 40) x = 0;
break;
case VK_LEFT:
SetConsoleTextAttribute (hStdout, FOREGROUND_INTENSITY | BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
gotoxy (5, 1);
printf("File");
if (getch () == 13)
{
gotoxy (5, 3);
printf("Hi!");
}
getch ();
break;
case VK_ESCAPE:
Loop = FALSE;
default:
break;
}
}
}
clrscr();
SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
return 0;
}
I have a problem with my menu cycle. If I press right or left key then the rectangle of red background color and white font color should cycle through the menu. I can't get it working. Any ideas?