VERY Basic GUI in Console

I just tried my hand at making a very simple GUI in a console window. My code seems like it would work, but it's not. The value starts out as a "1", which means that the left option is highlighted. When I hit the right arrow key it highlights the right option, but then it re-highlights the left option.

I tried a test and put a cout statement directly after the GUI's functions call. When it does the displaying, I found that it completely exits the functions and displays the statement. I have the call and the cout in a while loop, so then it goes back into the functions and it starts over on the left side.

The code is too large to post on here, so please send me an e-mail if you plan on helping me and I will send you my source code.

Please respond,
Tyler

tyler.is.number.one@gmail.com
Post the code. Try pastebin or posting in accross multiple posts (using [code][/code] tags).
http://pastebin.com/um6gQpK4

I forgot completely about pastebin. Thanks :)
I'm not sure how you are getting the arrow key inputs for your system but I suspect it's on lines 176-197. In those two conditions, both arrow keys appear to do exactly the same thing. Might that be part of the problem?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
if ( GetAsyncKeyState(VK_RIGHT) & 0x8000 )
    {
        if (highlight1 == 1) {
            highlight1++;
            goto fieldMenu;
        }
        if (highlight1 == 2) {
            highlight1--;
            goto fieldMenu;
        }
    }
    if ( GetAsyncKeyState(VK_LEFT) & 0x8000 )
    {
        if (highlight1 == 1) {
            highlight1++;
            goto fieldMenu;
        }
        if (highlight1 == 2) {
            highlight1--;
            goto fieldMenu;
        }
    }


If you look at it closely: If selection one if highlighted (highlight1 = 1) and the user hits RIGHT key, then highlight1 is increased to two, then it goes back to the beginning of the function and the screen is refreshed. Same thing for others but just reversed.

I don't see anything wrong with it, but if you do please share. haha. This code has given me so many problems.
Last edited on
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
if (left == true){
if ( GetAsyncKeyState(VK_RIGHT) & 0x8000 )
    {
        if (highlight1 == 1) {
            highlight1++;
            goto fieldMenu;
        }
        if (highlight1 == 2) {
            highlight1--;
            goto fieldMenu;
        }
    }
}
    else{
    if ( GetAsyncKeyState(VK_LEFT) & 0x8000 )
    {
        if (highlight1 == 1) {
            highlight1++;
            goto fieldMenu;
        }
        if (highlight1 == 2) {
            highlight1--;
            goto fieldMenu;
        }
    }
}


This way it will only evaluate the right key if it is even a possible selection. It's worth a shot. Are those key presses just standard windows.h?
How would: if (left == true) do anything?

And, yes they are standard windows.h
Topic archived. No new replies allowed.