Qbasicnews.com
menu selector - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html)
+--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html)
+--- Thread: menu selector (/thread-815.html)



menu selector - Techno - 05-10-2003

hi again.

wanted to know, what code would do the following:

when u press a key for example, or infact when u run the program, a menu appears BUT, I want this menu to highlight the text it is currently at and u have to use the up and down arrow keys to select the menu item.....

like for example, same or similar stuff when u load up XP/2K, and u ht F8 to select options (like safe mode etc..) similar to that?

thanks Smile


menu selector - toonski84 - 05-10-2003

wait, you can't properly access the keyboard or use text formatting, but you want to make an gui that accesses the internet?

*concerned frown*

well, anyhow, the arrow keys, using inkey$, is chr$(75) and chr$(77) for left and right, and chr$(72 and chr$(80) for up and down, if my memory serves me correctly.

as for text formatting, if you dont want to access the text buffer, you can just use color foreground, background and print out the same text to change the color.


menu selector - Techno - 05-10-2003

i thiink u got the wrong end of the stick

no, i ain't making a GUI (but it is nearly done) this is got nothing to do with a GUI

simple DOS window, what i want is a menu which will show options, then some sorta "bar" will allow u to select a highlighted option

???


try this - Meg - 05-10-2003

Code:
MaxChoice% = 5 'set number of menu choices

DIM Menu$(1 TO MaxChoice%) 'create array of choices

Menu$(1) = "Print text in Blue   " 'fill array with text
Menu$(2) = "Print text in Green  "
Menu$(3) = "Print text in Cyan   "
Menu$(4) = "Print text in Red    "
Menu$(5) = "Print text in Purple "

CurrentChoice% = 1 'sets initial highlighted spot
WHILE INKEY$ <> "": WEND 'clear keyboard buffer
DO
     CLS
     FOR i% = 1 TO MaxChoice%
          IF CurrentChoice% = i% THEN
               COLOR 0, 7 'highlight this option
          END IF
          PRINT i%; Menu$(i%)
          COLOR 7, 0
     NEXT i%
     DO
          k$ = UCASE$(INKEY$)  'get a keystroke into k$
     LOOP UNTIL k$ <> ""
     SELECT CASE k$
          CASE CHR$(0) + "H" 'up arrow key pressed
               CurrentChoice% = CurrentChoice% - 1
               IF CurrentChoice% = 0 THEN
                    CurrentChoice% = MaxChoice%
               END IF
          CASE CHR$(0) + "P" 'down arrow key pressed
               CurrentChoice% = CurrentChoice% + 1
               IF CurrentChoice% > MaxChoice% THEN
                    CurrentChoice% = 1
               END IF
     END SELECT
LOOP UNTIL k$ = CHR$(13) 'exit when enter is pressed

COLOR CurrentChoice%, 0
PRINT
PRINT "You have selected option"; CurrentChoice%
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = "": WEND

SYSTEM

*peace*

Meg.