Using a mouse in QuickBasic 
Author Message
 Using a mouse in QuickBasic

Hi, could anyone please send me some sample code or info on using a mouse
in
QuickBASIC 4.5 programmes on the PC.

Any help very much appreciated
Tracy Briscoe




Mon, 30 Nov 1998 03:00:00 GMT  
 Using a mouse in QuickBasic

G'Day All

Quote:


>Subject: Using a mouse in QuickBasic
>Date: 13 Jun 1996 03:36:24 GMT
>Hi, could anyone please send me some sample code or info on using a mouse
>in
>QuickBASIC 4.5 programmes on the PC.
>Any help very much appreciated
>Tracy Briscoe

Yes folks, it's time for another one of my mouse posts.
In QuickBasic 4.x and PDS 7.1 a relatively simple interrupt call is needed
and I have included a program modified from the one in an article from
Microsofts' knowledge base on one way to do it.
Another approach is to be found in Winers excellent text, available from the
Basic Home page. For QBASIC 1.x (the one that comes free with dos 5.0 and
up) you have to emulate an interrupt, code for this can be found in Douggie
GreensBasic FAQ (obtainable from the email address below, or the Basic home
page.


subject.
Basic Home Page,http://www.fys.ruu.nl/~bergmann/basic.html

'======= MY_MOUSE.BAS=========
' Here is a modified version of the mouse routines to be found
' in Microsoft Knowledge Base.
' These all use calls to interrupt 51 (&H33)

DEFINT A-Z
'$INCLUDE: 'qb.bi'
' Note: include QBX.BI for BASIC PDS 7.00
'---------------------------------------------------------------------
'---                                                               ---
'--- Mouse Library Routine Declarations                            ---
'---                                                               ---
'---------------------------------------------------------------------

DECLARE SUB MouseHandler (M0%, M1%, M2%, M3%)
DECLARE SUB MouseOff ()
DECLARE SUB MouseOn ()
DECLARE SUB MousePointerOff ()
DECLARE SUB MousePointerOn ()
DECLARE SUB GetMXY (mx%, my%)
DECLARE SUB MouseGetStatus (Lb%, Rb%, Cb%, Row%, Column%)
DECLARE SUB MouseSetPointer (Row%, Column%)
DECLARE SUB MouseSetWindow (TopRow%, LeftColumn%, BottomRow%, RightColumn%)
DECLARE FUNCTION MBtn% ()
DECLARE FUNCTION MouseInstalled% ()
DECLARE FUNCTION MouseReset% ()

CLS
'Is the mouse driver there?
Mouse = MouseInstalled%
IF Mouse THEN
        'Turn the mouse on
        Button = MouseReset%
        'Turn the pointer on
        MousePointerOn
        PRINT Button
END IF
'This count loop traps the delay in clearing the registers after
'a button is clicked. You can use MouseReset, but this slows execution
'DRAMATICALLY as reseting requires 0.28 secs
MouseTrap = 0
DO
        'a on key click, return key and location
        CALL MouseGetStatus(Lb%, Rb%, Cb%, Row%, Column%)
        LOCATE 10, 10: PRINT Lb%, Rb%, Row%, Column%, Count
        IF Lb% THEN
                MouseTrap = MouseTrap + 1
        ELSEIF Rb% THEN
                MouseTrap = MouseTrap + 1
                EXIT DO
        ELSE
                MouseTrap = 0
        END IF

LOOP UNTIL LEN(INKEY$)

CALL MouseOn
'Place the mouse where we want it
CALL MouseSetPointer(11, 5)
'Limit Mouse movement
CALL MouseSetWindow(15, 25, 20, 30)

DO
        CALL MouseGetStatus(Lb%, Rb%, Cb%, Row%, Column%)
        LOCATE 10, 10: PRINT Lb%, Rb%, Row%, Column%, Count
        IF Lb% THEN
                MouseTrap = MouseTrap + 1
        ELSEIF Rb% THEN
                MouseTrap = MouseTrap + 1
                IF MouseTrap = 1 THEN
                        EXIT DO
                END IF
        ELSE
                Count = 0
        END IF

LOOP UNTIL LEN(INKEY$)
CALL MouseOff

'------- Get Text Mode coordinates --------
SUB GetMXY (x, y) STATIC
  MouseHandler 3, 0, x, y                      'get GRAPHIC coordinates
  x = (x / 8) + 1                       'convert to TEXT coordinates
  y = (y / 8) + 1
END SUB

'------- Return Button Status -------
FUNCTION MBtn% STATIC
  MouseHandler 3, Buttons, 0, 0
  MBtn% = Buttons
END FUNCTION

'--------- Get Button and position status on click
'You can also get continuos x,y info using service 3
'in this case Button info=3, Button =0 and the
'select case statement checks Button
SUB MouseGetStatus (Lb%, Rb%, Cb%, x, y) STATIC
  ButtonInfo = 5
  Button = 0
  MouseHandler ButtonInfo, Button, y, x                      'get GRAPHIC coordinates
  SELECT CASE ButtonInfo
        CASE 0
                Lb% = 0
                Rb% = 0
                Cb% = 0
        CASE 1
                Lb% = 1
                Rb% = 0
        CASE 2
                Lb% = 0
                Rb% = 2
        CASE 3
                Cb% = 3
  END SELECT

  x = (x / 8) + 1                       'convert to TEXT coordinates
  y = (y / 8) + 1
END SUB

'------- Mouse Interrupt ------
SUB MouseHandler (M0%, M1%, M2%, M3%) STATIC
  DIM InRegs AS RegType, OutRegs AS RegType
  InRegs.ax = M0%
  InRegs.BX = M1%
  InRegs.CX = M2%
  InRegs.DX = M3%
  CALL Interrupt(51, InRegs, OutRegs)
  M0% = OutRegs.ax
  M1% = OutRegs.BX
  M2% = OutRegs.CX
  M3% = OutRegs.DX
END SUB

'------- Mouse Driver Active --------
FUNCTION MouseInstalled% STATIC
  DEF SEG = 0
  mseg% = 256 * PEEK(51 * 4 + 3) + PEEK(51 * 4 + 2)
  moff% = 256 * PEEK(51 * 4 + 1) + PEEK(51 * 4)
  IF mseg% OR moff% THEN
    DEF SEG = mseg%
    IF PEEK(moff%) = 207 THEN
      MouseInstalled% = 0
    ELSE
      MouseInstalled% = -1
    END IF
  ELSE
    MouseInstalled% = 0
  END IF
  DEF SEG
END FUNCTION

'------- Turn Mouse Off -------
SUB MouseOff STATIC
  MouseHandler 0, 0, 0, 0
END SUB

'------- Turn Mouse On --------
SUB MouseOn STATIC
  MouseHandler 0, 0, 0, 0                      'initialize mouse driver
  MouseHandler 1, 0, 0, 0                      'turn mouse cursor on
END SUB

'------- Hide the Mouse Cursor -------
SUB MousePointerOff STATIC
  CALL MouseHandler(2, 0, 0, 0)
END SUB

'------ Draw Mouse Cursor -------
SUB MousePointerOn STATIC
  MouseHandler 1, 0, 0, 0
END SUB

FUNCTION MouseReset% STATIC
  Present = 0
  Button = 0
  MouseHandler Present, Button, 0, 0
  IF Present THEN MouseReset% = Button ELSE MouseReset = 0
END FUNCTION

'------- Set Mouse Coordinates --------
SUB MouseSetPointer (y, x) STATIC
  MouseHandler 4, 0, (x - 1) * 8, (y - 1) * 8
END SUB

'------- Set Horizontal Minimum/Maximum -----
'------- Set Vertical Minimum/Maximum -------
SUB MouseSetWindow (y, x, v, h) STATIC
  MouseHandler 7, 0, (x - 1) * 8, (h - 1) * 8
  MouseHandler 8, 9, (y - 1) * 8, (v - 1) * 8
END SUB
'==========end mouse demo=============
Cheers! Ian
---------------------------------------------
Ian Musgrave Ph.D, Prince Henry's Institute of Medical Research
PO Box 5152, Clayton 3168, Australia.
Phone +61 3 550 4286 FAX +61 3 550 6125




Tue, 01 Dec 1998 03:00:00 GMT  
 Using a mouse in QuickBasic

You can download a mouse program in the Computer Programming Forum in
the QBASIC subfolder of the file library.  If you can't find it
there, download the solitaire program, and take each piece of the
mouse code out and figure out how to use it.  The forum is in
Categories, then Hobbies, then Computers or Computer Games, and then
search around for it.

Hackerman



Wed, 02 Dec 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using the mouse in QuickBASIC 4.5

2. want to use MOUSE with Quickbasic 7.1

3. QuickBasic 7.0 PDS UI Toolbox/Win 3.11 - SLOW MOUSE STARTUP

4. Mouse in QuickBasic 4.5

5. HELP:MOUSE input in QuickBASIC ????????????

6. HELP:MOUSE input in QuickBASIC ????????????

7. Mouse in QuickBasic

8. converting quickbasic code to ascii, or vb, or anything besides quickbasic

9. Using Extended/Expanded memory under QuickBasic

10. Anybody using QuickBasic to create CGI programs?

11. How does one go about Using EMS, or XMS memory in QuickBASIC, of VBDOS

12. Using Novell Netware API's with QuickBasic 4.5

 

 
Powered by phpBB® Forum Software