home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boston 2
/
boston-2.iso
/
DOS
/
PROGRAM
/
BASIC
/
POWBASIC
/
LIBRARY5
/
MICE.ZIP
/
MICE.DOC
< prev
next >
Wrap
Text File
|
1990-08-18
|
11KB
|
254 lines
' Contents of Mice.Obj
'
' The following routines allow you to use a mouse with your PowerBasic
' programs. You can use event trapping with a mouse if you follow these
' steps:
'
' 1. The user Must press both the left and right mouse buttons.
' 2. Use the 'On Pen' and 'Pen On' statements to control
' the program flow when the user presses the buttons in step 1.
'
' Perhaps some future release of PowerBasic will have an 'On Mouse'
' statement.
'
' These routines are distributed AS IS. By using the routines, you agree
' to accept full responsibility for any problems that may arise from said
' use.
'
' These routines are copyright 1990. All rights are reserved. You may
' freely include and use these routines in your programs. You may also
' freely distribute these routines, as long as this file accompanies the
' routines.
'
' Have Fun,
'
'
' Brett Jones
' [76166,2542] CompuServe
' B-Jones Genie
'-----------------------------------------------------------------------------
'declare function IsMouse%()
'-----------------------------------------------------------------------------
' IsMouse% Returns either a 0 (no mouse installed) or the number of buttons
' available on the mouse. If a mouse is installed, then the mouse pointer
' is reset to the middle of the screen, the display page is set to 0,
' the mouse pointer is hidden, user event handlers are disabled, light pen
' emulation is enabled, horizontal mickeys to pixels are set at 8 to 8,
' vertical mickeys to pixels are set to 16 to 8, double speed threshold is
' set to 64 mickeys/second, cursor defaults to block (text mode) or arrow
' (graphics mode) and the cursor limits are set to the entire screen.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub ShowMouse()
'-----------------------------------------------------------------------------
' ShowMouse Allows the mouse cursor to be displayed
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub HideMouse()
'-----------------------------------------------------------------------------
' HideMouse Hides the mouse cursor. Cursor movement tracking is continued
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare function WhereMouse&()
'-----------------------------------------------------------------------------
' WhereMouse& Returns a value from which you can determine the x and y
' coordinates (in pixels) of the mouse pointer. Example:
'
' b& = WhereMouse&
' x% = cint(b& mod 65536)
' y% = cint(b& / 65536)
'
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare function MouseButtons%()
'-----------------------------------------------------------------------------
' MouseButtons% Returns the status of the mouse buttons. If MouseButtons%
' equals 1, then the left button is down. If it equals 2, then the right
' button is down. If it equals 4, then the middle button is down. The
' value returned can reflect buttons pressed simultaneously.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub MoveMouse(integer,integer)
'-----------------------------------------------------------------------------
' MoveMouse(x,y) Moves the mouse cursor to horizontal (x) and vertical (y)
' pixel positions. Displays the cursor unless the cursor is hidden, or the
' new position lies within an excluded area.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub MouseWindow(integer,integer,integer,integer)
'-----------------------------------------------------------------------------
' MouseWindow(x1,x2,y1,y2) Sets the area in which the mouse cursor may be
' displayed. X1 and X2 are the minimum and maximum horizontal pixel
' coordinates; Y1 and Y2 are the minimum and maximum vertical pixel
' coordinates. The cursor will be moved into the area if necessary.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare function GetMickeys&()
'-----------------------------------------------------------------------------
' GetMickeys& Returns the number of mickeys since the last call to this
' function. See a reference manual for more information on this function
' (Function 0BH, Interrupt 33H).
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub SetMickeys(integer,integer)
'-----------------------------------------------------------------------------
' SetMickeys(x,y) Allows you to set the mickey to pixel ratios.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub ExcludeMouse(integer,integer,integer,integer)
'-----------------------------------------------------------------------------
' ExcludeMouse(x1,y1,x2,y2) Sets aside an area where the mouse cursor will
' not be displayed. x1 is the upper left X pixel coordinate, y1 is the
' upper left Y coordinate, x2 is the lower right X coordinate and y2 is the
' lower right Y coordinate.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub MouseSpeed(integer)
'-----------------------------------------------------------------------------
' MouseSpeed(speed) Sets the threshold speed for doubling pointer motion
' on the screen to the value specified in (speed). The default is 64
' mickeys per second.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub SaveMouse()
'-----------------------------------------------------------------------------
' SaveMouse Saves the mouse driver state. This must be used before
' executing a child program (Dos EXEC function). Use RestoreMouse on
' return.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub RestoreMouse()
'-----------------------------------------------------------------------------
' RestoreMouse Restores the mouse to the values set by SaveMouse.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub SetMouseSensitivity(integer,integer,integer)
'-----------------------------------------------------------------------------
' SetMouseSensitivity(HMickeys,VMickeys,DSpeed) Allows you to set the mickey
' to pixel ratio and the double speed at the same time.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub SetMousePage(integer)
'-----------------------------------------------------------------------------
' SetMousePage(pagenumber) Informs the mouse which page is to be used to
' display it's cursor. Note that you should also call ShowMouse if you
' change screen pages.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare function GetMousePage%()
'-----------------------------------------------------------------------------
' GetMousePage% Returns the page currently displaying the mouse cursor.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub ResetMouse()
'-----------------------------------------------------------------------------
' ResetMouse Acts exactly as IsMouse, except it does not return the number
' of buttons available on the mouse. All mouse info is reset to it's
' default state. (Note: This is not Function 21H, Int 33H - I am using
' Function 00 so the hardware is also initialized).
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare function MouseInfo&()
'-----------------------------------------------------------------------------
' MouseInfo& Returns information on the mouse. Example:
'
' a& = Mouseinfo&
' major& = (a& / 65536) / 256 ' Major version #
' minor& = (a& / 65536) mod 256 ' Minor version #
' type& = (a& mod 65536) / 256 ' Type of mouse:
' 1 = bus mouse
' 2 = serial mouse
' 3 = InPort mouse
' 4 = PS/2 mouse
' 5 = HP mouse
' irq& = (a& mod 65536) mod 256 ' IRQ Number
' vers = major& + (minor& / 10)
' print using "Version ####.## Type #### IRQ ####";vers,type&,irq&
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub MousePenOn()
'-----------------------------------------------------------------------------
' MousePenOn Allows the mouse to perform as a light pen in certain programs.
' By Pressing the left and right buttons at the same time, the mouse will
' emulate a light pen being triggered. Please note that a ResetMouse or
' an IsMouse% will also turn light pen emulation on.
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare sub MousePenOff()
'-----------------------------------------------------------------------------
' MousePenOff Disables the ability to use the mouse as a light pen.
' Light pen emulation will be turned on by calling MousePenOn, ResetMouse,
' or IsMouse%
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'declare function MouseType%()
'-----------------------------------------------------------------------------
' MouseType% returns the type of mouse installed, where:
' 1 = bus mouse
' 2 = serial mouse
' 3 = InPort mouse
' 4 = PS/2 mouse
' 5 = HP mouse
'-----------------------------------------------------------------------------