home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / basic / mlib30 / mlibview.bas < prev    next >
Encoding:
BASIC Source File  |  1994-02-21  |  7.2 KB  |  151 lines

  1.  DEFINT A-Z
  2.  '============================= MLIBVIEW.BAS ================================
  3.  '                  THIS SAMPLE PROGRAM IS PROVIDED AS IS.
  4.  '
  5.  ' You may modify/use this code in any way you wish, provided that you agree
  6.  ' that Terry Venn has no warranties, obligations or liabilities for any code
  7.  ' contained in this sample program.
  8.  '
  9.  ' MLIBVIEW.BAS is a sample program that displays all the mouse pointer
  10.  ' shapes contained in the MLIBSAM.SHP file.    
  11.  '
  12.  ' QB refers to: QuickBasic 4.5
  13.  ' VBDOS refers to: Visual Basic for DOS
  14.  '
  15.  ' To run this sample program from inside the QB environment, start the QB
  16.  ' editor by typing: QB/L MLIBN
  17.  '
  18.  ' To run this sample program from inside the VBDOS environment, start the
  19.  ' editor by typing: VBDOS/L MLIBF
  20.  '
  21.  ' QuickBasic and Visual Basic are trademarks of Microsoft Corporation.
  22.  '===========================================================================
  23.  
  24.  ' $INCLUDE: 'MLIB.BI'
  25.  
  26. DECLARE SUB Target ()
  27. DECLARE SUB MHold (B%)
  28. DECLARE SUB LoadShape (SHPRec() AS MOUSEtype, OpenSHP$)
  29.  
  30. '============================================================================
  31. SCREEN 12: CLS : CALL InitPointer(NumBut%)       'Initialize mouse.
  32. IF NumBut% = 0 THEN SCREEN 0: END                'No mouse.
  33.                                                  '
  34. CALL GetSpeedM(H%, V%, D%)                       'Get movement sensitivity.
  35. CALL SetSpeedM(50, 50, 50)                       'Use new settings
  36.                                                  '
  37. REDIM SHPRec(0) AS MOUSEtype                     'Shape data array.
  38.                                                  '
  39. CALL LoadShape(SHPRec(), "MLIBSAM.SHP")          'Open and load shape data.
  40.                                                  '
  41. CALL Target                                      '
  42.                                                  '
  43. PRINT "  <Press a key to end.> ";                '
  44. PRINT "<Mouse button = next shape>": ShowPointer '
  45.                                                  '
  46. ElNum% = 1                                       '
  47.                                                  '
  48. DO                                               '
  49.                                                  '
  50.    CALL GetButtonM(BUT%, X%, Y%)                 'Check for button press.
  51.                                                  '
  52.    IF BUT% THEN                                  '
  53.                                                  '
  54.       IF ElNum% < UBOUND(SHPRec, 1) THEN         'Last record.
  55.          ElNum% = ElNum% + 1                     '
  56.       ELSE                                       '
  57.          ElNum% = LBOUND(SHPRec, 1)              'First shape(second record).
  58.       END IF                                     '
  59.                                                  '
  60.       CALL HidePointer                           '
  61.                                                  '
  62.       LOCATE 1, 58: PRINT "Record:"; ElNum% - 1; '
  63.       PRINT SHPRec(ElNum%).FRM                   'Format (Trans or solid).
  64.                                                  '
  65.       CALL ShowPointer                           '
  66.                                                  '
  67.       SHPSTR$ = SHPRec(ElNum%).DAT               'Shape data.
  68.       HSX% = SHPRec(ElNum%).HTX                  'Hot X.
  69.       HSY% = SHPRec(ElNum%).HTY                  'Hot Y.
  70.                                                  '
  71.       CALL ChangePointer(SHPSTR$, HSX%, HSY%)    'Change shape of pointer.
  72.                                                  '
  73.       CALL MHold(BUT%)                           '
  74.                                                  '
  75.    END IF                                        '
  76.                                                  '
  77. LOOP WHILE INKEY$ = ""                           '
  78.                                                  '
  79. CALL SetSpeedM(H%, V%, D%)                       'Restore sensitivity state.
  80.                                                  '
  81. SCREEN 0: END                                    '
  82.                                                  '
  83. '============================================================================
  84.  
  85. '
  86. '****************************************************************************
  87. '*                                                                          *
  88. '*           --------------------------------------------------------       *
  89. '*           NOTE! THE FIRST RECORD IN EACH "SHP" FILE IS THE HEADER.       *
  90. '*           --------------------------------------------------------       *
  91. '*                                                                          *
  92. '* SHPRec() AS MOUSEtype     : The array that holds the shape data.         *
  93. '*             OpenSHP$      : The shape file that will be opened.          *
  94. '*                           :                                              *
  95. '* TYPE MOUSEtype            : Each record is 80 bytes.                     *
  96. '*      DLT    AS INTEGER    : 2  bytes for editor use.                     *
  97. '*      HTX    AS INTEGER    : 2  bytes for hotspot  X.                     *
  98. '*      HTY    AS INTEGER    : 2  bytes for hotspot  Y.                     *
  99. '*      MODE   AS STRING     : 10 bytes for solid or transparent ID.        *
  100. '*      SHPSTR AS STRING     : 64 bytes for shape data.                     *
  101. '* END TYPE                                                                 *
  102. '*                                                                          *
  103. '****************************************************************************
  104.                                                  '
  105. SUB LoadShape (SHPRec() AS MOUSEtype, OpenSHP$)  '
  106.                                                  '
  107. RecLen% = LEN(SHPRec(LBOUND(SHPRec, 1)))         'Length of a record.
  108.                                                  '
  109. FH% = FREEFILE                                   '
  110.                                                  '
  111. OPEN OpenSHP$ FOR RANDOM AS #FH% LEN = RecLen%   '
  112.                                                  '
  113. RecMax% = (LOF(FH%) \ RecLen%)                   'Calculate number of records.
  114.                                                  'Skip header(start at 2).
  115. REDIM SHPRec(2 TO RecMax%) AS MOUSEtype          'Dimension buffer to hold
  116.                                                  'all the shapes from disk.
  117. FOR Num% = 2 TO RecMax%                          'Load all the different
  118.                                                  'pointer shape data strings
  119.    GET #FH%, Num%, SHPRec(Num%)                  'plus hot spots off disk.
  120.                                                  '
  121. NEXT Num%                                        '
  122.                                                  '
  123. CLOSE #FH%                                       '
  124.                                                  '
  125. END SUB                                          '
  126.  
  127. SUB MHold (B%) STATIC'Loop while a mouse button is being held down.
  128.  
  129. DO: CALL GetButtonM(B%, X%, Y%)
  130.  
  131. LOOP WHILE B%
  132.  
  133. END SUB
  134.  
  135. SUB Target 'Draw a background.
  136.  
  137. LINE (15, 16)-(615, 465), 15, BF
  138.  
  139. Colr% = 0
  140.  
  141. FOR Size% = 220 TO 20 STEP -20
  142.   
  143.    Colr% = Colr% + 1
  144.    CIRCLE (320, 240), Size%, Colr%
  145.    PAINT (320, 240), Colr%, Colr%
  146.  
  147. NEXT
  148.  
  149. END SUB
  150.  
  151.