home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / basic / mouse.bas < prev    next >
Encoding:
BASIC Source File  |  1989-11-09  |  4.5 KB  |  152 lines

  1. '============================================================================
  2. '
  3. '    MOUSE.BAS - Mouse Support Routines for the User Interface Toolbox in
  4. '           Microsoft BASIC 7.0, Professional Development System
  5. '              Copyright (C) 1987-1989, Microsoft Corporation
  6. '
  7. ' NOTE:     This sample source code toolbox is intended to demonstrate some
  8. '           of the extended capabilities of Microsoft BASIC 7.0 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.     END IF
  93.  
  94.     MouseChecked = TRUE
  95.     
  96. END SUB
  97.  
  98. SUB MouseHide
  99.  
  100.     ' =======================================================================
  101.     ' Decrements internal cursor flag
  102.     ' =======================================================================
  103.  
  104.    MouseDriver 2, 0, 0, 0
  105.  
  106. END SUB
  107.  
  108. SUB MouseInit
  109.  
  110.     ' =======================================================================
  111.     ' Mouse driver's initialization routine
  112.     ' =======================================================================
  113.  
  114.     MouseDriver 0, 0, 0, 0
  115.  
  116. END SUB
  117.  
  118. SUB MousePoll (row, col, lButton, rButton) STATIC
  119.  
  120.     ' =======================================================================
  121.     ' Polls mouse driver, then sets parms correctly
  122.     ' =======================================================================
  123.  
  124.     MouseDriver 3, button, col, row
  125.     row = row / 8 + 1
  126.     col = col / 8 + 1
  127.                                                 
  128.     IF button AND 1 THEN
  129.         lButton = TRUE
  130.     ELSE
  131.         lButton = FALSE
  132.     END IF
  133.  
  134.     IF button AND 2 THEN
  135.         rButton = TRUE
  136.     ELSE
  137.         rButton = FALSE
  138.     END IF
  139.  
  140. END SUB
  141.  
  142. SUB MouseShow
  143.  
  144.     ' =======================================================================
  145.     ' Increments mouse's internal cursor flag
  146.     ' =======================================================================
  147.  
  148.     MouseDriver 1, 0, 0, 0
  149.  
  150. END SUB
  151.  
  152.