MOUSE?

 BBS: Inland Empire Archive
Date: 02-08-93 (06:22)             Number: 295
From: MARK BUTLER                  Refer#: NONE
  To: GREG DINERT                   Recvd: NO  
Subj: MOUSE?                         Conf: (2) Quik_Bas
Once upon a time Greg Dinert uttered these sage words to All:

 GD> How do you make a program in QuickBasic that uses a mouse?
 GD> What does it look like? Or can't you? Please help!

 The following snippet was graciously contributed by the former
 moderator of this conference Chris Wagner. I think this is exactly
 what you are looking for....
==========================8< Cut Here 8<=============================
'*** "Mouse Tester" by Chris Wagner
'***
REM $INCLUDE: 'QB.BI'  '*** use QBX.BI in PDS7
DECLARE SUB Mouseon ()
DECLARE SUB MouseOff ()
DECLARE SUB MouseSetHor (Min%, Max%)
DECLARE SUB MouseSetVert (Min%, Max%)
DECLARE SUB MouseLocate (Xpos%, Ypos%)
DECLARE SUB MouseStatus (Vert%, Hor%, Mbuttons$)
DECLARE FUNCTION MouseInstalled% ()
DIM SHARED RegX AS RegTypeX

    CLS
    LOCATE 2, 20: PRINT "Mouse Tester    By Chris Wagner";
    LOCATE 4, 20
    IF MouseInstalled% THEN
        PRINT "Mouse found and reset."
    ELSE
        PRINT "Mouse not found."
        END
    END IF
    LOCATE 14, 30: PRINT "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»";
    LOCATE 15, 30: PRINT "º  Press Q to Quit    º";
    LOCATE 16, 30: PRINT "º   or Click here     º";
    LOCATE 17, 30: PRINT "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ";
    CALL MouseSetHor(1, 80)
    CALL MouseSetVert(1, 25)
    CALL MouseLocate(20, 70)
    CALL Mouseon
    LOCATE 25, 1: PRINT "X Coord:    Y Coord:    ";
    DO
        CALL MouseStatus(Vert%, Hor%, Mbuttons$)
        LOCATE 25, 10: PRINT LTRIM$(STR$(Vert%)); "  ";
        LOCATE 25, 26: PRINT LTRIM$(STR$(Hor%)); "  ";
        LOCATE 25, 48: PRINT Mbuttons$;
        A$ = UCASE$(INKEY$)
        IF Mbuttons$ = "L  " OR A$ = "Q" THEN
            IF Vert% >= 14 AND Vert% <= 17 OR A$ = "Q" THEN
                IF Hor% >= 30 AND Hor% <= 52 OR A$ = "Q" THEN
                    MouseOff
                    CLS
                    SYSTEM
                END IF
            END IF
        END IF
    LOOP

'====[ EOF ]====

FUNCTION MouseInstalled%
    DEF SEG = 0
    MouseSeg& = 256& * PEEK(207) + PEEK(206)
    MouseOfs& = 256& * PEEK(205) + PEEK(204) + 2
    DEF SEG = MouseSeg&
    IF (MouseSeg& = 0 AND MouseOfs& = 0) OR PEEK(MouseOfs&) = 207 THEN
        MouseInstalled% = 0
        EXIT FUNCTION
    ELSE
        MouseInstalled% = -1
    END IF
    DEF SEG
    RegX.ax = 0
    CALL INTERRUPTX(&H33, RegX, RegX)
    IF RegX.ax = -1 THEN
        MouseInstalled% = -1
    ELSE
        MouseInstalled% = 0
    END IF
END FUNCTION

SUB MouseLocate (Xpos%, Ypos%)
    RegX.dx = (Xpos% * 8) - 1
    RegX.cx = (Ypos% * 8) - 1
    RegX.ax = 4
    CALL INTERRUPTX(&H33, RegX, RegX)
END SUB

SUB MouseOff
    RegX.ax = 2
    CALL INTERRUPTX(&H33, RegX, RegX)
END SUB

SUB Mouseon
    RegX.ax = 1
    CALL INTERRUPTX(&H33, RegX, RegX)
END SUB

SUB MouseSetHor (Min%, Max%)
    RegX.cx = (Min% * 8) - 1
    RegX.dx = (Max% * 8) - 1
    RegX.ax = 7
    CALL INTERRUPTX(&H33, RegX, RegX)
END SUB

SUB MouseSetVert (Min%, Max%)
    RegX.cx = (Min% * 8) - 1
    RegX.dx = (Max% * 8) - 1
    RegX.ax = 8
    CALL INTERRUPTX(&H33, RegX, RegX)
END SUB

SUB MouseStatus (Vert%, Hor%, Mbuttons$)
    RegX.ax = 3
    CALL INTERRUPTX(&H33, RegX, RegX)
    Vert% = (RegX.dx / 8) + 1
    Hor% = (RegX.cx / 8) + 1
    SELECT CASE RegX.bx
        CASE 0
            Mbuttons$ = "   "
        CASE 1
            Mbuttons$ = "L  "
        CASE 2
            Mbuttons$ = "  R"
        CASE 3
            Mbuttons$ = "L R"
        CASE 4
            Mbuttons$ = " C "
    END SELECT
END SUB
==========================8< Cut Here 8<=============================

 Hope this helps :-)

úùþ[-M-H-B-]þùú

--- timEd/B7 * Don't hate yourself in the morning, sleep till noon!
 * Origin:  Terminal Oasis, Portland OR  (1:105/330.5)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET