Graphics Menu in C++
Jan 31, 2020 at 4:28pm UTC
I am working on a project and I want to make a Graphics Menu. Issue which I am facing is that after it shows any text written in the function I've put in switch. it goes back to main menu. I want to make a function which stays on new function and once it directs to new function, It has nothing to do with main menu anymore. Until this function is called again.
I want it to be a simple menu function which directs me to function. Nothing else.
your help would mean allot! Thanks in advance.
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 99
#include<iostream>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<iomanip>
#include<fstream>
#include<windows.h>
using namespace std;
int main() {
system("cls" );
string Menu[3] = { " Admin" , " Customer" , " Exit" };
int pointer = 0;
bool flag=true ;
while (flag==true )
{
system("cls" );
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
cout << "Main Menu\n\n" ;
for (int i = 0; i < 3; ++i)
{
if (i == pointer)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 11);
cout << Menu[i] << endl;
}
else
{
SetConsoleTextAttribute ( GetStdHandle ( STD_OUTPUT_HANDLE), 15);
cout << Menu[i] << endl;
}
}
while (true )
{
if (GetAsyncKeyState(VK_UP) != 0)
{
pointer =pointer-1;
if (pointer == -1)
{
pointer = 2;
}
break ;
}
else if (GetAsyncKeyState(VK_DOWN) != 0)
{
pointer += 1;
if (pointer == 3)
{
pointer = 0;
}
break ;
}
else if (GetAsyncKeyState(VK_RETURN) != 0)
{
switch (pointer)
{
case 0:
{
admin_login();
Sleep(500);
break ;
}
case 1:
{
customer_sign();
Sleep(500);
break ;
}
case 2:
{
thank_you();
Sleep(800);
break ;
}
default :
{
cout<<"Invalid Input! " ;
}
}
}
}
Sleep(150);
}
return 0;
}
Last edited on Jan 31, 2020 at 4:35pm UTC
Jan 31, 2020 at 5:14pm UTC
Could you provide a minimal reproducible example?
Topic archived. No new replies allowed.