Thread: Menu Selection

  1. #1
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542

    Thumbs up Menu Selection

    Check out the menu selection I did!!

    Keys:
    Up = w
    Down = s
    Select = Enter

    If you want the code, please let me know

    New Download Available.. Scroll Down
    Last edited by Ruski; 10-06-2002 at 07:02 AM.
    what does signature stand for?

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    hmm... nice.

    why not release the code?

  3. #3
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Nice, but if I can make a suggestion, I would prefer to use the arrow-keys to select an option.
    Last edited by ripper079; 10-06-2002 at 03:45 PM.

  4. #4
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Yea.. that's what I tought, but I never used Arrow keys anywhere so I don't have experience yet..
    what does signature stand for?

  5. #5
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Here's the code & EXE. Have Fun!
    what does signature stand for?

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    damn you and your windows.h!

    (I'm in linux)

  7. #7
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Die Linux!
    what does signature stand for?

  8. #8
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    This is really cool dude! Thanks on showing me this.

  9. #9
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Sweet code! Just replace those if/else statements with switch/case statements and it will look even more sweet!!!

  10. #10
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    I tried using it for my calc. program, and it gave me 102 errors all saying "cout is an abigious " thing *you know what I'm talking about*. I tried it in MSVC++ 6.0 changing iostream to iostream.h and taking out the namespace thing, and changed (added) stuff to the menu. Then I tryed it again in Dev-C++ *new download* and it still did the same thing.

  11. #11
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Strange, I have modified the menu-system and it works. Donīt really know what the error is but I think is has something to to with multiple delcaration which the compiler is unable to choose the "right" one, for example when we have an overloaded function with a deafult value somthing like this

    Code:
    int func(int a);
    int func(int a, int b=10);
    
    int main()
    {
    //invoke which func ????
    cout << func(5);
    return 0;
    }
    If you post some code it would be easier to help

  12. #12
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Ruski:

    - It looks like variable choice[0] is unitialised when you use it here:
    >while (choice[0] != VK_RETURN)
    - Continuing with choice, why is it an array, size 1? Not much point in having an array of 1 items when you don't need to.

    - You have code in your header file. Ideally, you should have another .cpp file with the code in, leaving the declarations in the .h file. Then you link your main source with it when doing the compile.

    - With regards to the if/else if comments above, it would be an idea if you simply stored the menu in an array (2d char, or string), and looped through it to display it. That way, you can have an int holding the current index number that is being highlighted. Doing this would remove most of the if/else if statements. Here's something for you to ponder over:
    Code:
    #include <iostream>
    #include <string>
    
    using std::cout;
    using std::endl;
    using std::string;
    
    int main(void)
    {
        string mymenu[] = {"Option 1", "Option 2", "Option 3"};
        int HighlightMe = 1;
        
        for (int i = 0; i < sizeof (mymenu)/sizeof mymenu[0]; i++)
        {
            if (i == HighlightMe)
                cout <<"-->";
            else
                cout <<"   ";
            cout <<mymenu[i] <<endl;
        }
        
        return 0;
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  13. #13
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    I've compiled the code in Dev-C++ 5b and didn't have any errors/problems... It could be that I don't have much experience using CHARs so I did choice[0] etc...
    There are no copyrights, so feel free to use, edit, delete the code
    what does signature stand for?

  14. #14
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    That's probably why. I'm in MSVC++ 6.0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM
  4. menu selection trouble
    By Spectrum48k in forum C Programming
    Replies: 13
    Last Post: 11-20-2002, 11:06 PM