mouse

 BBS: Inland Empire Archive
Date: 04-17-93 (20:46)             Number: 303
From: JIM GIORDANO                 Refer#: NONE
  To: OWEN GIBBINS                  Recvd: NO  
Subj: mouse                          Conf: (2) Quik_Bas
OG>Could anyone give me a QB 4.5 (or -) program that will take
OG>input from the mouse/mouse driver, and print "Left",
OG>"Right", "Up", "Down", "Left Button", "Right button", or

'You'll probably get a bunch of progs to do what you asked.  Most
'write a half dozen subs to do various mouse things. I prefer one
'mouse sub, just pass it what I want to do with symbolic names
'like POLL, SHOW, SAVE, etc.
'  note: be sure to load library   qb mprog /L  or qbx mprog /L
DEFINT A-Z
TYPE RegType              'for CALL INTERRUPT
     ax    AS INTEGER
     bx    AS INTEGER
     cx    AS INTEGER
     dx    AS INTEGER
     bp    AS INTEGER
     si    AS INTEGER
     di    AS INTEGER
     flags AS INTEGER
     ds    AS INTEGER
     es    AS INTEGER
END TYPE
DIM SHARED regs AS RegType
DECLARE SUB Interrupt (IntNum AS INTEGER, inregs AS RegType,_
outregs AS RegType)
DECLARE SUB InterruptX (IntNum AS INTEGER, inregs AS RegType,_
outregs AS RegType)
DECLARE SUB Mouse (IntNum)

CLS
CONST Mreset = 0, Show = 1, Hide = 2, Poll = 3 'mouse interrupts
CONST Save = 22, Retrive = 23
DIM SHARED Mrow, Mcol, Lbutton, Rbutton _
'condition of mouse after Mouse Poll
Mouse Save      'save users mouse program
Mouse Mreset    'now reset mouse
Mouse Show      'show the mouse cursor
LOCATE 10, 22
PRINT "Press the escape key to end program"
DO
  Mouse Poll
  LOCATE 12, 14
  IF Lbutton THEN
    PRINT "Left Button pressed";
  ELSE
    PRINT "                   ";
  END IF
  PRINT USING "  ### ###  ### ###   "; Mrow; Mcol;
  IF Rbutton THEN
    PRINT "Right Button pressed"
  ELSE
    PRINT "                    "
  END IF
  LOCATE 14, 29
  IF Lbutton AND Rbutton THEN
    PRINT "Both Buttons pressed"
  ELSE
    PRINT "                    "
  END IF

LOOP WHILE INKEY$ <> CHR$(27)
Mouse Hide
Mouse Mreset      'reset the mouse
Mouse Retrive     'get old driver back
SYSTEM

SUB Mouse (IntNum) STATIC
regs.ax = IntNum  ' Calls interrupt 51 to invoke mouse functions
IF IntNum = 22 THEN  'save current driver.  First get size of
  regs.ax = 21       'buffer needed to save state of any
  Interrupt 51, regs, regs ' mouse handler currently running
  Bsize = regs.bx
  DIM buf((Bsize + 1) / 2) AS INTEGER 'make space for the buffer
  regs.ax = 22        '(use an integer buffer for compatibility
  regs.dx = VARPTR(buf(1))  ' between qb4.5 and basic7)
  regs.es = VARSEG(buf(1))  'now save it
  InterruptX 51, regs, regs
ELSEIF IntNum = 23 THEN     'restore old driver we saved earlier
  regs.dx = VARPTR(buf(1))
  regs.es = VARSEG(buf(1))
  InterruptX 51, regs, regs
ELSE
  Interrupt 51, regs, regs  'do whatever INTNUM the user wanted
END IF
IF IntNum = Poll THEN       'get position and button condition
  Mrow = regs.dx \ 8 + 1
  Mcol = regs.cx \ 8 + 1
  Lbutton = regs.bx AND 1: IF Lbutton THEN Lbutton = -1
  Rbutton = regs.bx AND 2: IF Rbutton THEN Rbutton = -1
END IF
END SUB

___
 X SLMR 2.1 X

--- Maximus 2.01wb
 * Origin: RoyaLink BBS *HST/DS* Oxnard, CA (805) 488-7430 (1:206/2503)
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