menu item selection question...?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mujeebrm

    #1

    menu item selection question...?

    /* menu.c, bc 5.02/tc 3, winxp */

    #include <stdio.h>
    #include <conio.h>

    #define uaro 72
    #define daro 80

    /* plz help me in this logic, how can i modify this my program
    of a simple menu so that when i press down arrow key it
    makes previous items bgcolor black and fgcolor white and
    selected items bgcolor red and fgcolor white and vice versa
    and when i press enter it should call respective function
    this should keep going on untill i press enter on exit menu item...?!
    plz help me in this regard. */

    void item1()
    {
    clrscr();

    printf(" in item 1 ");

    }

    void item2()
    {
    clrscr();

    printf(" in item 2 ");

    }

    void item3()
    {
    clrscr();

    printf(" in item 3 ");

    }



    int main()
    {
    int c=0, x=10, y=10, red=4,wite=15; char cho;

    clrscr();

    gotoxy(x,y);
    textattr(wite+ (red<<4) );
    cprintf("Item 1");

    gotoxy(10, y+=2);
    textattr(15+(0< <4) );
    cprintf("Item 2");

    gotoxy(10,y+=2) ;
    textattr(15+(0< <4) );
    cprintf("Item 3");



    gotoxy(x,y-=4);

    while(1)
    {
    c=getch();

    switch( c )
    {
    case daro:
    if(y==14)
    gotoxy(x, 14);
    else
    gotoxy(x, y+=2);
    break;
    case uaro:
    if(y==10)
    gotoxy(x,10);
    else
    gotoxy(x,y-=2);
    break;
    default:
    break;
    }
    }


    return 0;

    }

    /* thanx a lot,

    mujeebrm */


  • Jochen Kalmbach [MVP]

    #2
    Re: menu item selection question...?

    Hi mujeebrm!
    [color=blue]
    > /* plz help me in this logic, how can i modify this my program
    > [...]
    > clrscr();
    > [...]
    > gotoxy(x,y);[/color]

    This newsgroup is mainly for windows programming and in special for
    managed C++.
    Please try a borland (DOS) forum.

    --
    Greetings
    Jochen

    My blog about Win32 and .NET

    Comment

    Working...