home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / basic / mlib30 / mlibsam2.bas < prev    next >
Encoding:
BASIC Source File  |  1994-02-21  |  4.5 KB  |  118 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.  ' MLIBSAM2.BAS is a sample program that demonstrates the following routines:
  10.  '
  11.  ' GetSizeM%()      - Get size of mouse state.
  12.  ' SaveStateM()     - Save mouse state.
  13.  ' RestoreStateM()  - Restore mouse state.
  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 PrintMsg ()                          '
  30. DECLARE SUB ChangeState ()                       '
  31.                                                  '
  32. SCREEN 0: CLS                                    '
  33.                                                  '
  34. CALL InitPointer(X%)                             'Must initialize the mouse.
  35.                                                  '
  36. CALL ShowPointer                                 '
  37.                                                  '
  38. CALL PrintMsg                                    '
  39.                                                  '
  40.                                                  '
  41. BSize% = GetSizeM%                               'Get mouse state size, in
  42.                                                  'bytes.
  43. Buffer$ = SPACE$(BSize%)                         'Buffer to hold environment.
  44.                                                  '
  45. CALL SaveStateM(Buffer$, SaveErr%)               'Save the mouse environment.
  46.                                                  '
  47. IF NOT SaveErr% THEN                             '
  48.    CALL HidePointer                              '
  49.    CALL ChangeState                              '
  50.    SCREEN 0                                      '
  51. END IF                                           'NOTE! If Buffer$ is changed
  52.                                                  'in any way now that it holds
  53.                                                  'the mouse environment, you
  54.                                                  'will effectively lock up
  55.                                                  'your system.
  56.                                                  '
  57. CALL RestoreStateM(Buffer$, RestoreErr%)         'Restore mouse environment
  58.                                                  'to its original state prior
  59. CALL HidePointer                                 'to calling ChangeState.
  60.                                                  
  61. PRINT "Size of the mouse environment: "; BSize%; " bytes."
  62.  
  63. IF SaveErr% THEN
  64.    PRINT "Error in saving the mouse environment."
  65. ELSE
  66.    PRINT "Mouse environment was successfully saved."
  67. END IF
  68.  
  69. IF RestoreErr% THEN
  70.    PRINT "Error in restoring the mouse environment."
  71. ELSE
  72.    PRINT "Mouse environment was successfully restored."
  73.    PRINT "Pointer should be in the same position"
  74.    PRINT "as it was before we changed screen modes."
  75. END IF
  76.  
  77. PRINT
  78. PRINT "Press any key to continue..."
  79. CALL ShowPointer: a$ = INPUT$(1): CALL HidePointer
  80.  
  81. END
  82.  
  83. SUB ChangeState
  84.  
  85. SCREEN 9
  86. PRINT "Initializing the mouse..."
  87.  
  88. CALL InitPointer(X%)
  89. LOCATE 1, 1
  90. PRINT "What we have done here is change to a graphics mode and initialized the"
  91. PRINT "mouse (which will alter the mouse state). Now we could use this instance"
  92. PRINT "of the mouse to do whatever we like. After we are done in here we will"
  93. PRINT "restore the mouse state back to its original settings (SCREEN 0)."
  94. PRINT
  95. PRINT "Press a key to return..."
  96.  
  97. CALL ShowPointer
  98.  
  99. DO: LOOP UNTIL LEN(INKEY$)
  100.  
  101. CALL HidePointer
  102.  
  103. END SUB
  104.  
  105. SUB PrintMsg
  106.  
  107. PRINT "This example demonstrates how to save and restore the mouse environment."
  108. PRINT
  109. PRINT "First, move the pointer to a position you will remember. After a key has"
  110. PRINT "been pressed, we will save the mouse driver's environment and call a"
  111. PRINT "subroutine that will alter the state of the mouse."
  112. PRINT
  113. PRINT "Remember the pointer position."
  114. PRINT "Press any key to continue...": a$ = INPUT$(1)
  115.  
  116. END SUB
  117.  
  118.