Thread: Menu with the mouse

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    207

    Question Menu with the mouse

    Hi there,
    I am going to re-write some code that I did for the university, and I was thinking about including the mouse. For example, if I have a menu (with switch for example), will it mean a lot of work? Like in search of choosing option (1) I would click with the pointer on the option (1) New project.

    It's just to know if it's worth, or it's too much for somebody with not too much experience.

    Thanks for your comments

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    It depends on how well the 'get input' and 'do menu' are separated.

    If they are hopelessly inter-twined, then it will be hard work.

    If its a nice clean break, then another input routine (the mouse) should be fine, so long as the output it generates is the same as that from the keyboard.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    207

    Unhappy

    Salem, thanks for your reply, but I don't really understand you.

    This is one of the menu's I have done:


    ///////////////////////////////////////

    void
    MENU(void)
    {

    clrscr();

    printf("\n\nPlease choose one of the following options: \n\n\n");
    printf(" 1) Project menu\n");
    printf(" 2) Materials library menu \n");
    printf(" 3) Read instructions \n");
    printf(" 4) Exit \n");

    option = getch();

    while (option>='1'||option<'5')

    switch (option) {
    case '1':
    clrscr();
    project();
    break;

    case '2':
    clrscr();
    materials_library();
    break;

    case '3':
    clrscr();
    instructions ();
    break;

    case '4':
    clrscr();
    EXIT ();
    break;

    default:

    MENU();
    break;

    }

    }


    ///////////////

    And I'm using this compiler:

    Turbo C++

    Version 3.0

    Borland International


    Could you try to explain it again?

    Thanks a lot

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > option = getch();
    Well this is something you want to hide inside a 'get_input' function (so you hide the fact that its coming from either the k/b or the mouse.

    > default:
    > MENU();
    > break;
    This isn't good - you could call yourself recursively indefinitely.
    It's much better to use a while loop.

    I wonder if you're up to function pointers?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    22

    Thumbs up i have a solution

    hi gades,

    do u want to select yr menu by clicking the mouse( as we r doing in GUI )? i have a solution of this job in graphics mode.

    but i need to know yr requirements in details, then i'll try to solve yr problem.

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    207
    Thanks for the replies, and sorry I didn't reply as well; but I didn't get an e-mail telling me that I had any other answers.

    I've completelly changed my program, actually it's whole different program right now.

    I'll post some of my questions later on.

    Jackie: check your mail, and thanks.

  7. #7
    Registered User
    Join Date
    Dec 2001
    Posts
    21
    i think that it can be with assembly .
    with function 33h

    Mov AX,FnNo
    INT 33h

    the are many functions for the mouse ....

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. Problem with Mouse Over Menu!!! HELP!!!
    By SweeLeen in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2006, 02:10 AM
  4. Best "Menu" method?
    By SSJMetroid in forum Game Programming
    Replies: 11
    Last Post: 12-08-2005, 12:05 AM