home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / basic / bmag / altkey.bas next >
Encoding:
BASIC Source File  |  1994-04-13  |  3.2 KB  |  155 lines

  1. '─ Area: F-QUICKBASIC ─────────────────────────────────────────────────────────
  2. '  Msg#: 378                                          Date: 11 Apr 94  23:56:11
  3. '  From: John Waalkes                                 Read: Yes    Replied: No 
  4. '    To: All                                          Mark:                     
  5. '  Subj: AltKey                1/2
  6. '──────────────────────────────────────────────────────────────────────────────
  7. 'Here's something I cooked up to toggle the menu bar ala Micro$oft.
  8.  
  9.  
  10. REM ALTKEY.BAS Toggle the menu bar ala Micro$oft.
  11. REM Runs on QB, PDS, PB?
  12. REM Don't forget to run QB with the /l switch.
  13. ' With PB, you need to redo all register and interrupt stuff
  14. REM QBasic owners need not apply (although it wouldn't be hard to modify
  15. REM for use with PEEK's).
  16.  
  17. REM It's yours now...
  18.  
  19. DECLARE SUB NormBar ()
  20. DECLARE SUB PressDown ()
  21. DECLARE SUB Release1 ()
  22. DECLARE SUB Release2 ()
  23. TYPE RegType
  24.    AX AS INTEGER
  25.    BX AS INTEGER
  26.    CX AS INTEGER
  27.    DX AS INTEGER
  28.    BP AS INTEGER
  29.    SI AS INTEGER
  30.    DI AS INTEGER
  31.    FLAGS AS INTEGER
  32. END TYPE
  33.  
  34. DIM InputRegs AS RegType, OutputRegs AS RegType
  35.  
  36. CONST TRUE = -1
  37. CONST FALSE = 0
  38.  
  39. CONST White = 7
  40. CONST Black = 0
  41. CONST BrtWhite = 15
  42.  
  43. CLS
  44.  
  45. REM Setup menu bar
  46. CALL NormBar
  47.  
  48. DO
  49.    Choice$ = INKEY$
  50.    IF Choice$ = "" THEN
  51.  
  52.       REM Get the ALT key status. Set AH = &H02, BIOS Call &H16
  53.  
  54.       InputRegs.AX = &H200
  55.       CALL INTERRUPT(&H16, InputRegs, OutputRegs)
  56.  
  57.       REM Mask Bit in AL
  58.  
  59.       IF OutputRegs.AX AND 8 THEN
  60.          AltKey = TRUE
  61.       ELSE
  62.          REM Look to see if we're at the 2nd release
  63.  
  64.          IF AltKey = TRUE THEN
  65.             IF LeadingEdge = TRUE AND BarOn = FALSE THEN
  66.                CALL NormBar
  67.             END IF
  68.          END IF
  69.          AltKey = FALSE
  70.       END IF
  71.  
  72.       REM Is the ALT key pressed?
  73.  
  74.       IF AltKey = TRUE THEN
  75.  
  76.          REM LeadingEdge is used to keep BarOn from toggling every loop
  77.          REM Use it to tell when the menu bar is active.
  78.  
  79.          IF LeadingEdge = FALSE THEN
  80.             IF BarOn = FALSE THEN
  81.                BarOn = TRUE
  82.                LeadingEdge = TRUE
  83.             ELSE
  84.                BarOn = FALSE
  85.                LeadingEdge = TRUE
  86.             END IF
  87.          END IF
  88.       ELSE
  89.  
  90.          REM Reset LeadingEdge
  91.  
  92.          LeadingEdge = FALSE
  93.       END IF
  94.    END IF
  95.  
  96. REM First ALT pressdown. Second doesn't do anything.
  97.  
  98. IF LeadingEdge = TRUE AND BarOn = TRUE THEN
  99.    CALL PressDown
  100. END IF
  101. REM First ALT release
  102.  
  103. IF LeadingEdge = FALSE AND BarOn = TRUE THEN
  104.    CALL Release1
  105. END IF
  106.  
  107. REM Status Stuff.
  108.  
  109. COLOR White, Black
  110. LOCATE 2, 1
  111. PRINT SPACE$(80)
  112. PRINT "AltKey", AltKey
  113. PRINT "LeadingEdge", LeadingEdge
  114. PRINT "BarOn", BarOn;
  115.  
  116. LOOP WHILE Choice$ = ""
  117.  
  118. REM Normal Menu bar
  119. SUB NormBar
  120.  
  121. LOCATE 1, 1
  122. COLOR Black, White
  123. PRINT SPACE$(80)
  124.  
  125. LOCATE 1, 3
  126. PRINT "File";
  127.  
  128. END SUB
  129.  
  130. REM First Pressdown. Highlight the 'F'
  131. SUB PressDown
  132.  
  133. LOCATE 1, 3
  134.  
  135. COLOR BrtWhite, White
  136. PRINT "F";
  137.  
  138. COLOR Black, White
  139. PRINT "ile";
  140.  
  141. END SUB
  142.  
  143. REM First release. Highlight the 'F' and blackout the rest
  144. SUB Release1
  145.  
  146. LOCATE 1, 2
  147.  
  148. COLOR BrtWhite, Black
  149. PRINT " F";
  150.  
  151. COLOR White, Black
  152. PRINT "ile ";
  153.  
  154. END SUB
  155.