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

  1.  DEFINT A-Z
  2.  '============================= MLIBSAM1.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.  ' MLIBSAM1.BAS is a sample program that demonstrates the following routines:
  10.  '
  11.  ' GetSizeM%() - Get size of mouse state.
  12.  ' ShowPtrM%() - Restore mouse pointer on the screen no matter how many times
  13.  '               the pointer has been hidden.
  14.  '
  15.  ' QB refers to: QuickBasic 4.5
  16.  ' VBDOS refers to: Visual Basic for DOS
  17.  '
  18.  ' To run this sample program from inside the QB environment, start the QB
  19.  ' editor by typing: QB/L MLIBN
  20.  '
  21.  ' To run this sample program from inside the VBDOS environment, start the
  22.  ' editor by typing: VBDOS/L MLIBF
  23.  '
  24.  ' QuickBasic and Visual Basic are trademarks of Microsoft Corporation.
  25.  '===========================================================================
  26.  
  27.  ' $INCLUDE: 'MLIB.BI'                           '
  28.                                                  '
  29. DECLARE SUB GetInput (NumCalls%)                 '
  30. DECLARE SUB KP ()                                '
  31. DECLARE SUB M1 ()                                '
  32. DECLARE SUB M2 (X%)                              '
  33. DECLARE SUB MP ()                                '
  34.                                                  '
  35. SCREEN 0: CLS                                    '
  36.                                                  '
  37. CALL InitPointer(X%)                             'Must initialize the mouse.
  38.                                                  '
  39. M1                                               'Message 1.
  40.                                                  '
  41. CALL ShowPointer                                 '
  42.                                                  '
  43. GetInput NumCalls%                               '
  44.                                                  '
  45. FOR X = 1 TO NumCalls%                           'Hide X number of times.
  46.    CALL HidePointer                              '
  47. NEXT                                             '
  48.                                                  '
  49. M2 (NumCalls%)                                   'Message 2.
  50. MP                                               'Check mem.
  51.                                                  '
  52. BSize% = GetSizeM%                               'Get mouse state size, in
  53.                                                  'bytes.
  54. Buffer$ = SPACE$(BSize% * 2)                     'Build buffer for asm proc.
  55.                                                  '
  56. ErrNm% = ShowPtrM%(Buffer$)                      'Do it.
  57.                                                  '
  58. MP                                               'Print mem used.
  59.                                                  '
  60. Buffer$ = ""                                     'Release mem.
  61.                                                  '
  62. IF ErrNm% THEN                                   'Unable to complete task.
  63.                                                  '
  64.    PRINT "ERROR! Unable to complete task..."     'Insufficient buffer size.
  65.    BEEP                                          '
  66.                                                  '
  67. ELSE                                             'Job done.
  68.                                                  '
  69.    PRINT "Pointer is now visible again..."       '
  70.                                                  '
  71. END IF                                           '
  72.                                                  '
  73. KP                                               'Wait for a key press.
  74. CALL HidePointer: CLS : END                      'We are done.
  75.  
  76. '
  77. ' Get the number of times to hide the mouse pointer.
  78. '
  79. SUB GetInput (NumCalls%)
  80.  
  81. IP:
  82.  
  83. INPUT "Hide the pointer how many times [1 to 100]"; NumCalls%: CLS
  84. IF NumCalls% < 1 OR NumCalls% > 100 THEN PRINT "Redo..": GOTO IP
  85.  
  86. END SUB
  87.  
  88. SUB KP
  89.  
  90. VIEW PRINT
  91.  
  92. LOCATE 24
  93.  
  94. HidePointer
  95. PRINT "Press a key to continue..."
  96. ShowPointer
  97.  
  98. Hld$ = INPUT$(1)
  99.  
  100. CLS
  101.  
  102. END SUB
  103.  
  104. SUB M1
  105.  
  106. PRINT "                Demo on how to use the function ShowPtrM%."
  107. PRINT "                =================================================="
  108. PRINT
  109. PRINT "                First we must initialize the mouse and show the"
  110. PRINT "                mouse pointer. Then we will call HidePointer a"
  111. PRINT "                few times (pretending our program lost track of"
  112. PRINT "                how many times we hid the pointer)."
  113. PRINT
  114. PRINT "                Next we will call ShowPtrM%, this will restore"
  115. PRINT "                the mouse pointer on the screen."
  116. PRINT
  117. PRINT "                --------------------------------------------------"
  118. PRINT
  119. PRINT "                DECLARE FUNCTION ShowPtrM%(Buffer$)"
  120. PRINT "                Syntax: ErrNum% = ShowPtrM%(Buffer$)"
  121. PRINT
  122. PRINT "                ErrNum% returns a -1, if unsuccessful."
  123. PRINT "                See the manual for more information."
  124. PRINT
  125. PRINT "                --------------------------------------------------"
  126. PRINT "                                               Assembler function."
  127.  
  128. KP
  129.  
  130. PRINT
  131.  
  132. END SUB
  133.  
  134. SUB M2 (X%)
  135.  
  136. PRINT
  137. PRINT "       ------------------------------------------------------------"
  138. PRINT
  139. PRINT "       Mouse Driver keeps count by:"
  140. PRINT
  141. PRINT "        - Each call to HidePointer, will decrement count by one"
  142. PRINT
  143. PRINT "        - Each call to ShowPointer, will increment count by one."
  144. PRINT
  145. PRINT "        - Pointer is visible only when the count equals zero."
  146. PRINT
  147. PRINT "       What ShowPtrM% does:"
  148. PRINT
  149. PRINT "        - Check count value and reset it to zero."
  150. PRINT
  151. PRINT "       ------------------------------------------------------------"
  152. PRINT
  153. PRINT "       Now that we have called HidePointer "; X%; " times, the next job"
  154. PRINT "       is tell ShowPtrM% to restore the pointer on the screen."
  155.  
  156.  
  157. KP
  158.  
  159. END SUB
  160.  
  161. SUB MP STATIC
  162.  
  163. IF NOT X THEN
  164.    MEM1& = FRE(-1)
  165.    X = -1
  166. ELSE
  167.    MEM2& = FRE(-1)
  168.    MEM3& = MEM1& - MEM2&
  169.    PRINT "Amount of memory used: "; MEM3&; " bytes."
  170.    X = 0
  171. END IF
  172.  
  173. END SUB
  174.  
  175.