Console Menu

A while back I made a console menu and I wanted to share it with you. It is Windows only, (Cause I used WinAPI for colors) and it supports up and down arrows and space to select. Full colors, and uses a function pointer to execute the code that you want upon selection.

Example of usage:
1
2
3
4
5
Menu theMenu("My Menu"); //Menu title
theMenu.AddMenuItem("Option 1",&myfunc);//Add menu option
theMenu.AddMenuItem("Option 2", &myfunc2); //You can add as many as you want.
theMenu.SetColors(0x00,0x00,0x00); //Selected Color, Unselected Color, Title Color
theMenu.Loop(); //Run the menu  


The hex numbers for colors are the ones for WinAPI SetConsoleTextAttribute

I hope you like it!

Link:
https://www.dropbox.com/sh/crehsjmlgqtmnhv/trKVqPYutI
Last edited on
closed account (jwkNwA7f)
Cool!
I hope you like it!

I do. :D

Thanks for sharing it!
Did you even try it? *suspicious*
closed account (jwkNwA7f)
No...Because I'm on a mac right now, but it looks cool. :D

EDIT: And, I'll try when i get on my PC
Last edited on
OK then, but I hope that you do later. :D
If you use std::initializer_list in your Menu constructor, you can do something like:
1
2
3
4
Menu menu("My menu", {
    { "Option 1", &myfunc },
    { "Option 2", &myfunc },
});

which could be a little neater. Read up on std::initializer_list and std::pair to find out how to do it. Also, instead of using function pointers, there is a class in C++11 called std::function which is better to use.
Last edited on
OK. Thanks chrisname. :D
Topic archived. No new replies allowed.