using of left_right arrow button

This is a discussion on using of left_right arrow button within the A Brief History of Cprogramming.com forums, part of the Community Boards category; i would like to ask upon how to make the 4th and 5th menu of the command button to be ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1

    Unhappy using of left_right arrow button

    i would like to ask upon how to make the 4th and 5th menu of the command button to be highlighted after the left_right arrow button is been pressed.

    i hereby sincerly thanks everyone that would guide me along...
    thanks...

    this is some part of the program...

    void AddProfile (void)
    { char *menu[] = {"Sec 1 Combine", "Sec 2 Combine",
    "Sec 3 Combine", "Sec 4 Combine",
    "Sec 5 Combine"};
    char ch;
    int hpos, prehpos;

    DatabaseGraphics();

    Draw5CmdButtons(133, menu);

    setcolor(LIGHTBLUE);
    outtextxy(200, 202, "Select a Database to be loaded");
    setcolor(LIGHTBLUE);
    settextstyle(TRIPLEX_FONT, HORIZ_DIR, 2);
    outtextxy(195, 310, "Press ESC key to return");

    GraphicsPageInit();

    setcolor(YELLOW);
    outtextxy(141, 242, menu[0]);

    hpos = 0;
    do
    { prehpos = hpos;
    hpos = ArrowKeySelect(LEFT_RIGHT, hpos, 4, &ch);

    if(ch==L_ARROW || ch==R_ARROW)
    { setcolor(YELLOW);
    outtextxy(141+128*hpos, 242, menu[hpos]);

    setcolor(WHITE);
    outtextxy(141+128*prehpos, 242, menu[prehpos]);
    }
    }while(ch!=ESC);
    getch();
    }//end AddProfile

    void Draw5CmdButtons (int left, char *menu[])
    { int i;

    //draw Command Button for Sec 1, 2 and 3 Combine
    for(i=0; i<3; i++)
    { rectangle(left, 230, left+118, 260);
    rectangle(left+3, 233, left+115, 257);
    line(left, 230, left+3, 233);
    line(left+115, 257, left+118, 260);

    outtextxy(left+8, 242, menu[i]);

    setfillstyle(SOLID_FILL, RED);
    floodfill(left+10, 231, WHITE);
    setfillstyle(SOLID_FILL, LIGHTRED);
    floodfill(left+10, 258, WHITE);

    left+=128;
    }

    //draw the Command Button for Sec 4 Combine
    rectangle(193, 267, 311, 297);
    rectangle(196, 270, 308, 294);
    line(193, 267, 196, 270);
    line(308, 294, 311, 297);

    outtextxy(201, 279, menu[3]);

    setfillstyle(SOLID_FILL, RED);
    floodfill(203, 268, WHITE);
    setfillstyle(SOLID_FILL, LIGHTRED);
    floodfill(203, 295, WHITE);

    //draw the Command Button for Sec 5 Combine
    rectangle(321, 267, 439, 297);
    rectangle(324, 270, 436, 294);
    line(321, 267, 324, 270);
    line(436, 294, 439, 297);

    outtextxy(329, 279, menu[4]);

    setfillstyle(SOLID_FILL, RED);
    floodfill(331, 268, WHITE);
    setfillstyle(SOLID_FILL, LIGHTRED);
    floodfill(331, 295, WHITE);
    }//end Draw5CmdButtons

    int ArrowKeySelect (int type, int curpos, int maxpos, char *ch)
    { char key1, key2;

    key1 = type ? L_ARROW : U_ARROW;
    key2 = type ? R_ARROW : D_ARROW;

    *ch = GetKey();

    if(*ch == key1)
    curpos = (curpos>0) ? curpos-1 : maxpos;
    else if(*ch == key2)
    curpos = (curpos<maxpos) ? curpos+1 : 0;

    return curpos;
    }//end ArrowKeySelect

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,544
    Do you know that cursor keys (and function keys) are reported in TWO bytes?

    Code:
    ch = getch();
    if ( ch == '\0' ) {
        // extended key - such as arrow
        ch = 256 + getch();
    }
    // 0..255 are normal keys
    // 256..511 are extended keys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. allegro, small problem
    By IM back! in forum C++ Programming
    Replies: 8
    Last Post: 11-20-2008, 01:29 PM
  2. elliptical button
    By geek@02 in forum Windows Programming
    Replies: 0
    Last Post: 11-21-2006, 01:15 AM
  3. writing text over a deleted button
    By algi in forum Windows Programming
    Replies: 4
    Last Post: 05-02-2005, 11:32 AM
  4. Window won't display on button command!?
    By psychopath in forum Windows Programming
    Replies: 6
    Last Post: 06-22-2004, 08:12 PM
  5. Arrow keys
    By Nutshell in forum C Programming
    Replies: 5
    Last Post: 03-27-2002, 10:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21