Mouse Event Handler

 BBS: Inland Empire Archive
Date: 12-01-92 (17:23)             Number: 379
From: MATTHEW BEASLEY              Refer#: NONE
  To: MIKE KERR                     Recvd: NO  
Subj: Mouse Event Handler            Conf: (2) Quik_Bas
MK>I don't believe QuickBASIC is capable of mouse interrupts.  I think PDS
MK>can do it, though.  There is an interrupt you can call that will act as
MK>an event handler, but you need to know the starting address of the
MK>routine you want to call.

Of course QuickBasic can use mouse interrupts.  Here's some code that I
wrote (remember to load QB.LIB before running) to show mouse usage in
QuickBasic:

   --------------------------CUT HERE-------------------------------
DECLARE SUB c ()
DECLARE SUB mnu ()
DECLARE SUB left ()
DECLARE SUB right ()
DECLARE SUB middle ()
'$INCLUDE: 'QB.BI'
DIM SHARED regs AS RegTypeX
regs.ax = &H0
regs.bx = 8
regs.cx = 7
CALL INTERRUPTX(&H33, regs, regs) 'Reset driver and read status
regs.ax = &H1
CALL INTERRUPTX(&H33, regs, regs) 'Show mouse cursor
regs.ax = &H4
regs.cx = 1                       'Column
regs.dx = 1                       'Row
CALL INTERRUPTX(&H33, regs, regs) 'Position mouse cursor
LOCATE 1, 1: PRINT " ";
mnu
DO
a$ = ""
a$ = INKEY$: IF a$ = CHR$(27) THEN GOTO EXT
regs.ax = &H3
CALL INTERRUPTX(&H33, regs, regs)
IF regs.bx = 0 THEN c
IF regs.bx = 1 THEN left
IF regs.bx = 2 THEN right
IF regs.bx = 3 THEN middle
LOOP
EXT:
regs.ax = &H2
CALL INTERRUPTX(&H33, regs, regs) 'Hide mouse cursor
CLS : PRINT "Thanks for using MouseTest!": END

SUB c
LOCATE 15, 24: PRINT "     "
LOCATE 16, 24: PRINT "     "
LOCATE 15, 37: PRINT "     "
LOCATE 16, 37: PRINT "     "
LOCATE 15, 49: PRINT "     "
LOCATE 16, 49: PRINT "     "
END SUB

SUB left
LOCATE 15, 24: PRINT STRING$(5, 219)
LOCATE 16, 24: PRINT STRING$(5, 219)
END SUB

SUB middle
LOCATE 15, 37: PRINT STRING$(5, 219)
LOCATE 16, 37: PRINT STRING$(5, 219)
END SUB

SUB mnu
CLS : COLOR 7, 0:
PRINT "             /-------------------------------------------------\";
PRINT "             |        MouseTest Ver. 1                         |";
PRINT "             |        Written By: Matthew Beasley              |";
PRINT "             |        Released: 12/01/92                       |";
PRINT "             |        Copyright 1992 by Matthew Beasley        |";
PRINT "             \-------------------------------------------------/";
PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT
PRINT "                       Left        Middle       Right";
PRINT "                      /-----\      /-----\     /-----\";
PRINT "                      |     |      |     |     |     |";
PRINT "                      |     |      |     |     |     |";
PRINT "                      \-----/      \-----/     \-----/";
PRINT : PRINT : PRINT
PRINT "                               Press ESC to end"
COLOR 7, 0
END SUB

SUB right
LOCATE 15, 49: PRINT STRING$(5, 219)
LOCATE 16, 49: PRINT STRING$(5, 219)
END SUB
   ---------------------------CUT HERE--------------------------------


 * OLX 2.2 * 3 kinds of people: Those who can count & those who can't


--- WM v2.04/92-0178
 * Origin: Paradox of Arkansas *Wildcat 3.0* 501-646-7158 (1:19/121)
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