home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / MSPROG.ZIP / MSDEMO.BAS < prev    next >
BASIC Source File  |  1993-11-26  |  2KB  |  82 lines

  1. 'Mouse Coordinate Display Demo
  2. 'By: Brad Wilson
  3. '11/26/1993
  4.  
  5. 'This program requres that the UITBxxx.QLB or similar quick library be
  6. 'loaded. This program was written using UITBEFR.QLB.
  7.  
  8. 'Note: Most of this program is just graphics stuff (I get a little carried
  9. '      away now and then). The main part of the program is in lines 52 to 54.
  10.  
  11. 'Required Include Files (these are from PDS's User Interface Toolbox)
  12. '$INCLUDE: 'general.bi'
  13. '$INCLUDE: 'mouse.bi'
  14.  
  15. DECLARE SUB getmouse (lb%, rb%, x%, y%) 'lb%   - left  button
  16.                                         'rb%   - right button
  17.                                         'x%,y% - x and y coordinates
  18.  
  19.         SCREEN 12: CLS
  20.  
  21.         'Set up some semi-spiffy graphics
  22.         FOR i% = 0 TO 14
  23.          PALETTE i%, 65536 * INT(i% * 4.5)
  24.         NEXT i%
  25.         PALETTE 15, 63
  26.  
  27.         c = 0: cflag = .6
  28.         FOR i% = 0 TO 625
  29.          LINE (i%, 0)-(i%, 479), c
  30.          c = c + cflag
  31.          IF c <= 0 OR c >= 14 THEN cflag = -cflag
  32.          IF c < 0 THEN
  33.           c = 0
  34.          ELSEIF c > 14 THEN
  35.           c = 14
  36.          END IF
  37.         NEXT i%
  38.  
  39.         'Turn on Mouse and show coordinates at upper-left
  40.         'until user presses a key.
  41.  
  42.         LINE (0, 0)-(152, 32), 14, B    'Create a "Window" for
  43.         LOCATE 1, 1: PRINT SPACE$(19)   'coordinate display.
  44.         LOCATE 2, 1: PRINT SPACE$(19)
  45.  
  46.         MouseShow 'Defined in mouse.bi, included in UITBxxx.QLB
  47.  
  48.         c = 63: cflag = 1  'Used for color fading
  49.         DO
  50.          k$ = INKEY$
  51.  
  52.          getmouse lb%, rb%, x%, y%                      'Here's the heart of
  53.          LOCATE 1, 1: PRINT "x ->"; x%; " y ->"; y%     'the program.
  54.          LOCATE 2, 1: PRINT "lb->"; lb%; " rb->"; rb%   'Teeny, eh?
  55.  
  56.          PALETTE 15, 65536 * (63 - c) + c
  57.          c = c + cflag
  58.          IF c <= 0 OR c >= 63 THEN cflag = -cflag
  59.          IF c < 0 THEN
  60.           c = 0
  61.          ELSEIF c > 63 THEN
  62.           c = 63
  63.          END IF
  64.         LOOP UNTIL LEN(k$) 'Loop until keypress
  65.  
  66.         MouseHide 'Defined in mouse.bi, included in UITBxxx.QLB
  67.  
  68. SCREEN 0: WIDTH 80: CLS
  69. END
  70.  
  71. SUB getmouse (lb%, rb%, x%, y%)
  72.  
  73.         m1% = 3                          'Call Function 3:
  74.         MouseDriver m1%, m2%, m3%, m4%   '
  75.  
  76.         x% = m3%
  77.         y% = m4%
  78.         IF m2% AND 1 THEN lb% = -1 ELSE lb% = 0
  79.         IF m2% AND 2 THEN rb% = -1 ELSE rb% = 0
  80. END SUB
  81.  
  82.