home *** CD-ROM | disk | FTP | other *** search
- '*******************************************************************
- '* QBTEST.BAS *
- '* *
- '* Demonstrates three-line menu using QuickBASIC *
- '* *
- '* To load QBMOUSE.QLB into memory with QuickBASIC: *
- '* QB /L QB.QLB *
- '*******************************************************************
-
- DEFINT A-Z
- DECLARE SUB Mouse (m0%, M1%, M2%, M3%)
-
- ' Clear the display
- CLS
-
- ' Display simple instructions for user
- PRINT "QBTEST - Mouse demonstration using QuickBASIC 4.5"
- PRINT
- PRINT "Use mouse to highlight a menu option."
- PRINT "Press either button to select option. "
-
- ' Check for mouse, resetting it in the process
- M1 = 0
- Mouse M1, M2, M3, M4
-
- ' Quit if mouse wasn't found
- IF M1 = 0 THEN
- PRINT "Error: Mouse not found "
- SYSTEM
- END IF
-
- ' Initialize menu pointer to first option
- menuPtr = 1
-
- ' Initialize count of accumulated vertical mouse motion
- motion = 0
-
- ' Set flag to update menu first time
- wFlag = 1
-
- ' Main loop starts here
- DO
-
- ' Update the menu only when necessary
- IF wFlag = 1 THEN
- wFlag = 0
-
- ' Print first line of the menu, highlighted if selected
- IF menuPtr = 1 THEN
- COLOR 0, 7
- ELSE
- COLOR 7, 0
- END IF
- LOCATE 10, 29
- PRINT " 1. First menu option "
-
- ' Print second line of the menu, highlighted if selected
- IF menuPtr = 2 THEN
- COLOR 0, 7
- ELSE
- COLOR 7, 0
- END IF
- LOCATE 11, 29
- PRINT " 2. Second option "
-
- ' Print third line of the menu, highlighted if selected
- IF menuPtr = 3 THEN
- COLOR 0, 7
- ELSE
- COLOR 7, 0
- END IF
- LOCATE 12, 29
- PRINT " 3. Third option "
-
- ' Be sure highlighting is turned off
- COLOR 7, 0
-
- ' End of the menu updating
- END IF
-
- ' Accumulate vertical mouse motion counts
- M1 = 11
- Mouse M1, M2, M3, M4
- motion = motion + M4
-
- ' Move up the menu if enough mouse motion
- IF motion < -17 THEN
- motion = 0
- IF menuPtr > 1 THEN
- menuPtr = menuPtr - 1
- wFlag = 1
- END IF
- END IF
-
- ' Move down the menu if enough mouse motion
- IF motion > 17 THEN
- motion = 0
- IF menuPtr < 3 THEN
- menuPtr = menuPtr + 1
- wFlag = 1
- END IF
- END IF
-
- ' Check if left button pressed
- M1 = 5
- M2 = 0
- Mouse M1, M2, M3, M4
- IF M2 <> 0 THEN
- PRINT "Left button used to select option", menuPtr
- SYSTEM
- END IF
-
- ' Check if right button pressed
- M1 = 5
- M2 = 1
- Mouse M1, M2, M3, M4
- IF M2 <> 0 THEN
- PRINT "Right button used to select option", menuPtr
- SYSTEM
- END IF
-
- ' Loop back until one of the buttons is pressed
- LOOP
-
- ' All done
- END
-