PULLDOWN PT 1/2

 BBS: Inland Empire Archive
Date: 12-26-92 (00:06)             Number: 375
From: SCOTT MAYFIELD               Refer#: NONE
  To: JEFF JOHNSTON                 Recvd: NO  
Subj: PULLDOWN PT 1/2                Conf: (2) Quik_Bas
' 
-------
' PULLDOWN.BAS -- By Scott Mayfield ' PD as of 12/25/92...Yes, I program on XMas... '
-------
' NOTES: This menu demo responds to the ALT+FirstLetter key combinations ' that you should be familiar with when using the QB environment. ' ' There are probably better ways of doing this... But this isn't ' meant to be a full featured pull down menu system. It's limited ' by nesting levels, hot key combinations, etc... It's meant only ' as a demo to give you an idea of where to start... DECLARE SUB HideMenu () DECLARE SUB ShowMenu (MenuBar$) DECLARE SUB InitMenu (Menu$(), MenuBar$) DECLARE SUB DropMenu (MenuIndex%) DECLARE FUNCTION AltKeyPressed% () DEFINT A-Z CONST FALSE = 0 ' Some constants to use throughout the program CONST TRUE = NOT FALSE CONST MENUITEMS = 8 ' Number of items on our main pull down menu ' This is global and used by some SUBs... AltX$ = CHR$(0) + CHR$(45) ' Hot Key definations... AltF$ = CHR$(0) + CHR$(33) AltE$ = CHR$(0) + CHR$(18) AltV$ = CHR$(0) + CHR$(47) AltS$ = CHR$(0) + CHR$(31) AltR$ = CHR$(0) + CHR$(19) AltD$ = CHR$(0) + CHR$(32) AltC$ = CHR$(0) + CHR$(46) AltO$ = CHR$(0) + CHR$(24) DIM Menu$(1 TO MENUITEMS) ' Set up our menu... CALL InitMenu(Menu$(), MenuBar$) CLS ' Show prompt LOCATE 25, 1 PRINT "Press Alt-X to exit demo..." Infinity% = FALSE ' Set up for infinate loop DO IF AltKeyPressed% THEN ' If we are pressing ALT, CALL ShowMenu(MenuBar$) ' display our menu, otherwise ELSE ' we don't want to see it. CALL HideMenu ' One of these is CALLed END IF ' for EVERY pass through the ' loop. It can be speeded up ' by keeping a flag to tell ' if the menu is currently ' visible...I'll leave that ' to you. Ch$ = INKEY$ ' Look for a keypress... SELECT CASE Ch$ CASE AltF$: CALL DropMenu(1) LOCATE 10, 10 ' Just to show it's DOING something... PRINT "Alt F Pressed..." CASE AltE$: CALL DropMenu(2) LOCATE 10, 10 ' Just to show it's DOING something... PRINT "Alt E Pressed..." ' ------------------------------------------------------------- ' CASE statements for ALT V, S, R, D, C, O have been ommited to ' shorten the post...They are identical in form... ' ------------------------------------------------------------- CASE AltX$: ' Exit the demo... EXIT DO CASE ELSE ' This is where you can handle any other keys ' that your program may need to interpret... END SELECT ' At this point, you can do any other items ' that you want your program to do "in the ' background" while polling the keyboard. ' Try to stay away from time intensive tasks ' as that will slow the polling rate. Branching ' to another SUB from here will SUSPEND the ' menu polling until you return. LOOP UNTIL Infinity% COLOR 7, 0 ' Clean up... CLS END --- TMail v1.31 * Origin: Toledo's TBBS, 4+ gigs, 50,000 files 313-854-6001 (1:234/2)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET