home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 3.ddi / MOUSE.BA$ / MOUSE.bin
Encoding:
Text File  |  1990-06-24  |  4.5 KB  |  153 lines

  1. '============================================================================
  2. '
  3. '    MOUSE.BAS - Mouse Support Routines for the User Interface Toolbox in
  4. '           Microsoft BASIC 7.1, Professional Development System
  5. '              Copyright (C) 1987-1990, Microsoft Corporation
  6. '
  7. ' NOTE:     This sample source code toolbox is intended to demonstrate some
  8. '           of the extended capabilities of Microsoft BASIC 7.1 Professional
  9. '           Development system that can help to leverage the professional
  10. '           developer's time more effectively.  While you are free to use,
  11. '           modify, or distribute the routines in this module in any way you
  12. '           find useful, it should be noted that these are examples only and
  13. '           should not be relied upon as a fully-tested "add-on" library.
  14. '
  15. '  PURPOSE: These routines are required for mouse support in the user
  16. '           interface toolbox, but they may be used independently as well.
  17. '
  18. '  For information on creating a library and QuickLib from the routines
  19. '  contained in this file, read the comment header of GENERAL.BAS.
  20. '
  21. '============================================================================
  22.  
  23. DEFINT A-Z
  24.  
  25. '$INCLUDE: 'general.bi'
  26. '$INCLUDE: 'mouse.bi'
  27. '$INCLUDE: 'menu.bi'
  28.  
  29. COMMON SHARED /uitools/ GloMenu      AS MenuMiscType
  30. COMMON SHARED /uitools/ GloTitle()   AS MenuTitleType
  31. COMMON SHARED /uitools/ GloItem()    AS MenuItemType
  32.  
  33. SUB MouseBorder (row1, col1, row2, col2) STATIC
  34.  
  35.     ' =======================================================================
  36.     ' Sets max and min bounds on mouse movement both vertically, and
  37.     ' horizontally
  38.     ' =======================================================================
  39.  
  40.     MouseDriver 7, 0, (col1 - 1) * 8, (col2 - 1) * 8
  41.     MouseDriver 8, 0, (row1 - 1) * 8, (row2 - 1) * 8
  42.  
  43. END SUB
  44.  
  45. SUB MouseDriver (m0, m1, m2, m3) STATIC
  46.  
  47.     DIM regs AS RegType
  48.  
  49.     IF MouseChecked = FALSE THEN
  50.         DEF SEG = 0
  51.  
  52.         MouseSegment& = 256& * PEEK(207) + PEEK(206)
  53.         MouseOffset& = 256& * PEEK(205) + PEEK(204)
  54.  
  55.         DEF SEG = MouseSegment&
  56.  
  57.         IF (MouseSegment& = 0 AND MouseOffset& = 0) OR PEEK(MouseOffset&) = 207 THEN
  58.             MousePresent = FALSE
  59.             MouseChecked = TRUE
  60.             DEF SEG
  61.         END IF
  62.     END IF
  63.  
  64.     IF MousePresent = FALSE AND MouseChecked = TRUE THEN
  65.         EXIT SUB
  66.     END IF
  67.  
  68.     ' =======================================================================
  69.     ' Calls interrupt 51 to invoke mouse functions in the MS Mouse Driver.
  70.     ' =======================================================================
  71.     
  72.     regs.ax = m0
  73.     regs.bx = m1
  74.     regs.cx = m2
  75.     regs.dx = m3
  76.  
  77.     Interrupt 51, regs, regs
  78.  
  79.     m0 = regs.ax
  80.     m1 = regs.bx
  81.     m2 = regs.cx
  82.     m3 = regs.dx
  83.  
  84.     IF MouseChecked THEN EXIT SUB
  85.  
  86.     ' =======================================================================
  87.     ' Check for successful mouse initialization
  88.     ' =======================================================================
  89.  
  90.     IF m0 AND NOT MouseChecked THEN
  91.         MousePresent = TRUE
  92.         DEF SEG
  93.     END IF
  94.  
  95.     MouseChecked = TRUE
  96.     
  97. END SUB
  98.  
  99. SUB MouseHide
  100.  
  101.     ' =======================================================================
  102.     ' Decrements internal cursor flag
  103.     ' =======================================================================
  104.  
  105.    MouseDriver 2, 0, 0, 0
  106.  
  107. END SUB
  108.  
  109. SUB MouseInit
  110.  
  111.     ' =======================================================================
  112.     ' Mouse driver's initialization routine
  113.     ' =======================================================================
  114.  
  115.     MouseDriver 0, 0, 0, 0
  116.  
  117. END SUB
  118.  
  119. SUB MousePoll (row, col, lButton, rButton) STATIC
  120.  
  121.     ' =======================================================================
  122.     ' Polls mouse driver, then sets parms correctly
  123.     ' =======================================================================
  124.  
  125.     MouseDriver 3, button, col, row
  126.     row = row / 8 + 1
  127.     col = col / 8 + 1
  128.                                                 
  129.     IF button AND 1 THEN
  130.         lButton = TRUE
  131.     ELSE
  132.         lButton = FALSE
  133.     END IF
  134.  
  135.     IF button AND 2 THEN
  136.         rButton = TRUE
  137.     ELSE
  138.         rButton = FALSE
  139.     END IF
  140.  
  141. END SUB
  142.  
  143. SUB MouseShow
  144.  
  145.     ' =======================================================================
  146.     ' Increments mouse's internal cursor flag
  147.     ' =======================================================================
  148.  
  149.     MouseDriver 1, 0, 0, 0
  150.  
  151. END SUB
  152.  
  153.