'============================================================================ ' ' MYMOUSE.BAS - Mouse Support Routines for the User Interface Toolbox in ' Microsoft BASIC 7.1, Professional Development System ' Copyright (C) 1987-1990, Microsoft Corporation '******** as modified by Peter Bird, UCLA, April-June 1992 ***************** ' NOTE: This sample source code toolbox is intended to demonstrate some ' of the extended capabilities of Microsoft BASIC 7.1 Professional ' Development system that can help to leverage the professional ' developer's time more effectively. While you are free to use, ' modify, or distribute the routines in this module in any way you ' find useful, it should be noted that these are examples only and ' should not be relied upon as a fully-tested "add-on" library. ' ' PURPOSE: These routines are required for mouse support in the user ' interface toolbox, but they may be used independently as well. ' ' For information on creating a library and QuickLib from the routines ' contained in this file, read the comment header of GENERAL.BAS. ' '============================================================================ DEFINT A-Z '$INCLUDE: 'general.bi' '$INCLUDE: 'mymouse.bi' SUB MouseBorder (row1, col1, row2, col2) STATIC ' ======================================================================= ' Sets max and min bounds on mouse movement both vertically, and ' horizontally ' ======================================================================= MouseDriver 7, 0, (col1 - 1) * 8, (col2 - 1) * 8 MouseDriver 8, 0, (row1 - 1) * 8, (row2 - 1) * 8 END SUB SUB MouseClick (row, col, lButton, rButton) STATIC 'report whether either button has been pushed since last call, 'and if so, where last push was '(if not, col and row are unchanged) ' 'LEFT SIDE: ax = 5 bx = 0 MouseDriver ax, bx, cx, dx IF bx THEN lButton = -1 'TRUE row = dx col = cx ELSE lButton = 0 'FALSE END IF ' 'RIGHT SIDE: ax = 5 bx = 1 MouseDriver ax, bx, cx, dx IF bx THEN rButton = -1 'TRUE row = dx col = cx ELSE rButton = 0 'FALSE END IF ' END SUB SUB MouseDriver (m0, m1, m2, m3) STATIC DIM regs AS RegType IF MouseChecked = FALSE THEN DEF SEG = 0 MouseSegment& = 256& * PEEK(207) + PEEK(206) MouseOffset& = 256& * PEEK(205) + PEEK(204) DEF SEG = MouseSegment& IF (MouseSegment& = 0 AND MouseOffset& = 0) OR PEEK(MouseOffset&) = 207 THEN MousePresent = FALSE MouseChecked = TRUE DEF SEG END IF END IF IF MousePresent = FALSE AND MouseChecked = TRUE THEN EXIT SUB END IF ' ======================================================================= ' Calls interrupt 51 to invoke mouse functions in the MS Mouse Driver. ' ======================================================================= regs.ax = m0 regs.bx = m1 regs.cx = m2 regs.dx = m3 Interrupt 51, regs, regs m0 = regs.ax m1 = regs.bx m2 = regs.cx m3 = regs.dx IF MouseChecked THEN EXIT SUB ' ======================================================================= ' Check for successful mouse initialization ' ======================================================================= IF m0 AND NOT MouseChecked THEN MousePresent = TRUE DEF SEG END IF MouseChecked = TRUE END SUB DEFSNG A-Z SUB MouseHide ' ======================================================================= ' Decrements internal cursor flag ' WARNING: Multiple hidings of mouse require multiple showings to restore! ' ======================================================================= MouseDriver 2, 0, 0, 0 END SUB DEFINT A-Z SUB MouseInit ' ======================================================================= ' Mouse driver's initialization routine ' ======================================================================= MouseDriver 0, 0, 0, 0 END SUB SUB MousePut (row, col) STATIC 'places mouse cursor at desired position bx = 0 'not used? MouseDriver 4, bx, col, row END SUB DEFSNG A-Z SUB MouseShow ' ======================================================================= ' Increments mouse's internal cursor flag ' WARNING: Multiple hidings of mouse require multiple Showings to restore! ' ======================================================================= MouseDriver 1, 0, 0, 0 END SUB DEFINT A-Z SUB MouseXYB (row, col, lButton, rButton) STATIC ' ======================================================================= ' Requests graphics-mode row and column from mouse driver, plus whether ' either of the buttons is down ' ======================================================================= MouseDriver 3, button, col, row IF button AND 1 THEN lButton = -1 ' TRUE ELSE lButton = 0 ' FALSE END IF IF button AND 2 THEN rButton = -1 ' TRUE ELSE rButton = 0 ' FALSE END IF END SUB