home *** CD-ROM | disk | FTP | other *** search
-
- =======================================================================
- Routine Reference Section
- =======================================================================
-
- Mouse interface for QuickBASIC V4.x, Microsoft BASIC 6.X, and the
- Microsoft BASIC Professional Development System 7.X.
-
- Written by Tony Elliott (CIS 76220,2575)
- EllTech Development, Inc.
- 4374 Shallowford Industrial Pkwy
- Marietta, GA 30066
-
- For QBNews and released into the Public Domain.
- =======================================================================
-
- MouseAlreadyReset%
-
- Checks to see if the current program has already reset the mouse.
- If so, returns the number of buttons the mouse has, otherwise returns
- zero.
-
- From BASIC:
-
- DECLARE FUNCTION MouseAlreadyReset% ()
-
- Buttons% = MouseAlreadyReset%
- IF Buttons% THEN
- PRINT "Mouse with"; Buttons%;" buttons has already been reset."
- ELSE
- PRINT "Mouse has not yet been reset."
- END IF
-
- -----------------------------------------------------------------------
-
- MouseCancelEvent
-
- Cancels (disables) active mouse event handler.
-
- From BASIC:
-
- DECLARE SUB MouseCancelEvent ()
- CALL MouseCancelEvent
-
- -----------------------------------------------------------------------
-
- MouseExit
-
- This code should be called prior to program termination. It performs
- such tasks as releasing memory allocated by the mouse routines and
- unhooking the mouse routines from the mouse driver's "User Defined
- Event" handler. Failure to call this routine prior to program
- termination could result is a system lockup if the MouseSetEvent
- routine has been previously called and the MouseCancelEvent routine was
- not.
-
- During the call to the MouseReset routine, we attempted to add this
- routine to BASIC's B_OnExit chain. This allows BASIC itself to call
- this code when your program terminates or restarts. In other words, you
- probably won't have to worry about it. It is a pretty rare occurrence
- that the B_OnExit call would fail - more than 32 other procedures would
- have to be registered before it would fail.
-
- But for those faint of heart, we've gotcha covered. The function
- MouseOnExit% returns true if we are successfully included in the
- B_OnExit chain. If it returns false, the you need to call this routine
- (MouseExit) manually before your program terminates. For example:
-
- IF NOT MouseOnExit% THEN
- CALL MouseExit
- END IF
- END
-
- -----------------------------------------------------------------------
-
- MouseGetEventInfo
-
- Returns the values captured during the last mouse event
-
- From BASIC:
-
- DECLARE SUB MouseGetEventInfo(EventType%, Lb%, Rb%, Cb%, Row%, _
- Column%)
- CALL MouseGetEventInfo(EventType%, Lb%, Rb%, Cb%, Row%, Column%)
-
- EventType% is bit-mapped and indicates what condition(s) triggered the
- mouse event. Just "AND" Event% with a value associated with one of your
- defined events. If the result is non-zero then that was what triggered
- the event. For example:
-
- PRINT "Event cause: "
- IF Event% AND 4 THEN '4 is value for "left release"
- PRINT "Left button was released."
- ELSEIF Event% AND 16 THEN '16 is value for "right release"
- PRINT "Right button was released."
- END IF
-
- See MouseSetEvent for a complete listing of all available events and
- their respective values.
-
- The other parameters reflect the state of the mouse at the time of the
- last event. See MouseGetStatus for info on how to interpret their
- meanings.
-
- -----------------------------------------------------------------------
-
- MouseGetInfo
-
- Returns information about the current mouse hardware and software:
-
- MajorVer% - The Major mouse driver version (7 for 7.04). It is
- returned as zero if the mouse has not been initialized.
-
- MinorVer% - The Minor mouse driver version (4 for 7.04)
-
- MouseType% - 1 = bus mouse, 2 = serial mouse, 3 = InPort mouse,
- 4 = PS/2 mouse, 5 = HP mouse
-
- Irq% - The hardware Irq line that the mouse driver is using. 0 =
- PS/2, or 2, 3, 4, 5, or 7 for all others.
-
- From BASIC:
-
- DECLARE SUB MouseGetInfo(MajorV%, MinorV%, MouseType%, Irq%)
- CALL MouseGetInfo(MajorV%, MinorV%, MouseType%, Irq%)
-
- -----------------------------------------------------------------------
-
- MouseGetPage%
-
- Returns the display page the mouse pointer is currently visible on. See
- MouseSetPage to change the pointer's current display page. Returns -1
- if the mouse has not yet been initialized.
-
- From BASIC:
-
- DECLARE FUNCTION MouseGetPage% ()
-
- PRINT "The current pointer display page is" MouseGetPage%
-
- -----------------------------------------------------------------------
-
- MouseGetSensitivity
-
- Returns the current mouse "sensitivity" related settings. See the
- routines MouseSetRatio and MouseSetDblSpd for more information
-
- From BASIC:
-
- DECLARE SUB MouseGetSensitivity (VertRatio%, HorizRatio%, _
- DblSpd%)
- CALL MouseGetSensitivity (VertRatio%, HorizRatio%, DblSpd%)
-
- -----------------------------------------------------------------------
-
- MouseGetStatus
-
- Returns the current "real time" state of the mouse buttons and the
- mouse pointers current position in row/column coordinates. A value of -
- 1 (TRUE) returned for Lb%, Rb% or Cb% indicates that the respective
- button is currently pressed and a value of zero (FALSE) indicates the
- button is not pressed.
-
- From BASIC:
-
- DECLARE SUB MouseGetStatus(Lb%, Rb%, Cb%, Row%, Column%)
-
- CALL MouseGetStatus(Lb%, Rb%, Cb%, Row%, Column%)
-
- -----------------------------------------------------------------------
-
- MouseInstalled%
-
- Check to see if a mouse is installed WITHOUT resetting it. The
- MouseReset function will still have to be invoked before the other
- mouse routines will function.
-
- From BASIC:
-
- DECLARE FUNCTION MouseInstalled% ()
-
- IF MouseInstalled% THEN
- PRINT "A mouse IS installed."
- ELSE
- PRINT "A mouse was not detected."
- END IF
-
- -----------------------------------------------------------------------
-
- MouseMovement
-
- Returns the net mouse displacement since the last call to this routine.
- In other words, it tells you how many "Mickeys" (approx 1/200th of an
- inch) the mouse has moved from it's position the last time this routine
- was called.
-
- From BASIC:
-
- DECLARE SUB MouseMovement (Rows%, Columns%)
-
- CALL MouseMovement (Rows%, Columns%)
-
- -----------------------------------------------------------------------
-
- MousePixelsOff
-
- Sets an internal flag which tells us to return mouse coordinates in
- base 1 row/column format. This the default. You need to call this
- routine only if you have previously called the MousePixelsOn routine
- and you wish to return to row/column coordinates.
-
- From BASIC:
-
- DECLARE SUB MousePixelsOff ()
-
- CALL MousePixelsOff
-
- -----------------------------------------------------------------------
-
- MousePixelsOn
-
- Sets an internal flag which tells us to return mouse coordinates in
- pixel format. The default is to return base 1 row/column coordinates
- like BASIC uses. Use the routine MousePixelsOff to reset the coordinate
- system back to row/columns.
-
- From BASIC:
-
- DECLARE SUB MousePixelsOn ()
-
- CALL MousePixelsOn
-
- -----------------------------------------------------------------------
-
- MousePointerOff
-
- This routine makes the mouse pointer visible. Please see the special
- note under the MousePointerOn routine for details about the mouse
- driver's internal counter.
-
- Note: Even though the mouse pointer is not visible, the driver
- continues to track the mouse pointer position.
-
- From BASIC:
-
- DECLARE SUB MousePointerOff ()
-
- CALL MousePointerOff
-
- -----------------------------------------------------------------------
-
- MousePointerOn
-
- Displays the mouse pointer (cursor) and cancels any previous mouse
- exclusion area defined with the routine MouseSetExclusionArea.
-
- Note: Each time this routine is called, the mouse driver increments an
- internal counter. The MousePointerOff routine decrements the
- counter. The MouseReset routine set the counter to an initial
- value of -1. While the counter < 0 the mouse pointer will be
- hidden and when the counter >= 0 the pointer is visible.
- In other words, if MousePointerOff was called three
- successive times, MousePointerOn would have to be called three
- times before the pointer would be physically turned back on.
-
- From BASIC:
-
- DECLARE SUB MousePointerOn () 'This is optional.
-
- CALL MousePointerOn
-
- -----------------------------------------------------------------------
-
- MousePressInfo%
-
- Returns the number of times the specified mouse button has been pressed
- since the last time this routine was called. It also returns the
- position where the specified button was pressed.
-
- From BASIC:
-
- DECLARE FUNCTION MousePressInfo% (Button%, Row%, Column%)
-
- NumberOfPresses% = MousePressInfo%(Button%, Row%, Column%)
-
- On entry, Button% = 0 for the left button
- 1 for the right button
- 2 for the center button (if any)
-
- On exit, the result of the function indicates the number of times the
- specified button has been pressed since this routine was last called.
- Row% and Column% will contain the coordinates where the specified
- button was last pressed. The current coordinate system is used (See
- MousePixelsOn and MousePixelsOff).
-
- -----------------------------------------------------------------------
-
- MouseReleaseInfo%
-
- Returns the number of times the specified mouse button has been
- released since the last time this routine was called. It also returns
- the position where the specified button was last released.
-
- From BASIC:
-
- DECLARE FUNCTION MouseReleaseInfo% (Button%, Row%, Column%)
-
- NumberOfReleases% = MouseReleaseInfo%(Button%, Row%, Column%)
-
- On entry, Button% = 0 for the left button
- 1 for the right button
- 2 for the center button (if any)
-
- On exit, the result of the function indicates the number of times the
- specified button has been released since this routine was last called.
- Row% and Column% will contain the coordinates where the specified
- button was last released. The current coordinate system is used (See
- MousePixelsOn and MousePixelsOff).
-
- -----------------------------------------------------------------------
-
- MouseReset%
-
- Initializes the mouse. The mouse driver is initialized to the following
- state:
-
- - Mouse pointer is at the center of the screen
- - Display page for mouse set to 0
- - Mouse pointer is hidden (off)
- - Mouse pointer shape is the default arrow shape in the graphics
- video modes or a reverse block in the text modes.
-
- From BASIC:
-
- DECLARE FUNCTION MouseReset% ()
-
- Buttons% = MouseReset%
- IF Buttons% THEN
- PRINT "Mouse with";Buttons%;" buttons is installed and reset."
- ELSE
- PRINT "Mouse not detected."
- END IF
-
- -----------------------------------------------------------------------
-
- MouseRestoreState
-
- Restores the state of the mouse if previously saved with the
- MouseSaveState routine. See the MouseSaveState routine for additional
- usage notes.
-
- From BASIC:
-
- DECLARE SUB MouseRestoreState ()
- CALL MouseRestoreState
-
- -----------------------------------------------------------------------
-
- MouseSaveState
-
- Save the current mouse state including, position, visibility, and other
- characteristics. You could use this routine prior to SHELLing another
- program which could use the mouse.
-
- The MouseRestoreState routine restores the previous state of the mouse.
-
- This routine make a call to BASIC's SETMEM code to release enough
- memory to DOS to save the mouse state. When the MouseRestoreState
- routine is CALLed, the memory is released from DOS and given back to
- BASIC.
-
- Note: This routine can be DECLAREd as a SUB or a FUNCTION. If declared
- as an integer FUNCTION, -1 (TRUE) is returned if the state was
- saved successfully and 0 (FALSE) if unsuccessful (due to
- insufficient memory). If you don't care about the success or
- failure of the operation, you can simply DECLARE it as a SUB
- without parameters.
-
- From BASIC:
-
- DECLARE SUB MouseSaveState ()
- CALL MouseSaveState
-
- -or-
-
- DECLARE FUNCTION MouseSaveState% ()
- IF MouseSaveState% THEN
- PRINT "Mouse state saved successfully"
- ELSE
- PRINT "Insufficient memory to save mouse state!"
- END IF
-
- -----------------------------------------------------------------------
-
- MouseSetDblSpd
-
- Sets the mouse pointer "double speed threshold". If the mouse is moved
- faster than the specified number of MickeysPerSecond, the mouse pointer
- will kick into overdrive and effectively move twice as fast. The
- default is 64 Mickeys (approx 1/3 inch) per second.
-
- Passing a large value (such as 10,000) effectively disables the speed
- doubling effect.
-
- From BASIC:
-
- DECLARE SUB MouseSetDblSpd (MickeysPerSecond%)
-
- CALL MouseSetDblSpd(200) 'Set it to 1 inch per second
-
- -----------------------------------------------------------------------
-
- MouseSetEvent
-
- This routine sets up a "Mouse Event" handler which can be trapped in
- your BASIC program via "ON UEVENT".
-
- The following are the available events that can be trapped. Any
- combination of events are acceptable. Each event has a value associated
- with it. Define the desired event by assigning its value to the
- EventMask% parameter when calling this routine. Combinations of events
- can be obtained by adding the values of the respective events. For
- example, to set an event for "left button release" and "right button
- release", simply add the values together: 4 + 16 = 20.
-
- 1 = Any mouse movement
- 2 = Left button pressed
- 4 = Left button released
- 8 = Right button pressed
- 16 = Right button released
- 32 = Center button pressed
- 64 = Center button released
-
- From BASIC:
-
- DECLARE SUB MouseSetEvent (EventMask%)
- CALL MouseSetEvent(20) 'Traps left or right button release
-
- ON UEVENT GOSUB MouseEvent
- UEVENT ON
-
- DO 'Continue processing event until
- A$ = INKEY$ ' a key is pressed.
- LOOP UNTIL LEN(A$)
- END
-
- MouseEvent:
- CALL MouseGetEventInfo(Event%, Lb%, Rb%, Cb%, Row%, Column%)
- PRINT "Mouse event occurred: - "
- IF Event% AND 4 THEN
- PRINT "Left Button was released."
- END IF
- IF Event% AND 16 THEN
- PRINT "Right Button was released."
- END IF
- PRINT "Mouse location:" Row% "," Column%
- RETURN
-
- -----------------------------------------------------------------------
-
- MouseSetExclusionArea
-
- If the mouse pointer is moved into the rectangular area of the screen
- defined by this routine, the mouse pointer will be turned off.
-
- From BASIC:
-
- DECLARE SUB MouseSetExclusionArea (TopRow%, LeftColumn%, _
- BottomRow%, RightColumn%)
-
- CALL MouseSetExclusionArea (1, 1, 3, 80)
-
- -----------------------------------------------------------------------
-
- MouseSetHardwarePointer
-
- Defines the shape and characteristics of the mouse pointer used in text
- video modes. The "hardware" cursor is simply a character block which
- the programmer can control the starting scan line and the ending scan
- line (i.e., the size and shape of the block). When the hardware cursor
- is moved over the screen, it appears as a blinking block.
-
- From BASIC:
-
- DECLARE SUB MouseSetHardwarePointer(StartScan%, EndScan%)
-
- CALL MouseSetHardwarePointer(0, 7)
-
- -----------------------------------------------------------------------
-
- MouseSetPage
-
- Sets the current mouse pointer display page. Be sure that your current
- video mode supports the specified page number. See BASIC's SCREEN
- statement documentation for more info.
-
- From BASIC:
-
- DECLARE SUB MouseSetPage(PointerPage%)
- CALL MouseSetPage(1)
-
- -----------------------------------------------------------------------
-
- MouseSetPointer
-
- Set the mouse pointer position. The format for the coordinates is based
- on the most recent call to either of MousePixelsOn or MousePixelsOff.
- If neither have been previously called, row/column coordinates is the
- default.
-
- If coordinates provided are outside the physical screen or outside of
- the vertical or horizontal limits set by the MouseSetWindow routine,
- the coordinates are adjusted automatically.
-
- From BASIC:
-
- DECLARE SUB MouseSetPointer(Row%, Column%)
-
- CALL MouseSetPointer(Row%, Column%)
-
- -----------------------------------------------------------------------
-
- MouseSetRatio
-
- Sets the ratio between the amount mouse physical mouse movement
- (Mickeys) and the amount of movement reflect by the mouse pointer on
- the screen. The value passed in reflects the number of Mickeys required
- to move the pointer 8 pixels. The default is 8 Mickeys per 8 pixels (1
- Mickey per pixel) horizontal and 16 Mickeys per 8 pixels (2 Mickeys per
- pixel) of vertical movement. A value between 1 and 32767 Mickeys can be
- specified.
-
- From BASIC:
-
- DECLARE SUB MouseSetRatio (VertRatio%, HorizRatio%)
-
- CALL MouseSetRatio(8, 4) 'Doubles mouse sensitivity
-
- -----------------------------------------------------------------------
-
- MouseSetSoftwarePointer
-
- Sets characteristics of mouse "software" pointer. This type of pointer
- is used only in text modes and physically manipulates whatever
- character and attribute that is under it. The values passed in AndMask%
- and in XorMask%) determine exactly how the character and attribute will
- be manipulated.
-
- From BASIC:
-
- DECLARE SUB MouseSetSoftwarePointer (AndMask%, XorMask%)
-
- CALL MouseSetSoftwarePointer(&H77ff, &H7700)
-
- The AND mask determines what part of the character/attribute pair will
- be passed through and the XOR mask determines which of the resulting
- bits will be toggled. In each case, the low byte of the integer applies
- to the character and the high bytes applies to the attribute.
-
- -----------------------------------------------------------------------
-
- MouseSetWindow
-
- Set the coordinates for a window in which the mouse pointer is allowed
- to move. By default, the pointer is allowed to move freely over the
- entire screen. This routine allows you to limit the mouse pointer's
- movement to a specific rectangular area of the screen.
-
- From BASIC:
-
- DECLARE SUB MouseSetWindow(TopRow%, LeftColumn%, BottomRow%,_
- RightColumn%)
-
- CALL MouseSetWindow(10, 10, 20, 70)
-
- -----------------------------------------------------------------------
-
- MouseWaitForRelease
-
- Waits for all mouse buttons to be released before returning control to
- the calling program.
-
- From BASIC:
-
- DECLARE SUB MouseWaitForRelease ()
-
- CALL MouseWaitForRelease
-
- -----------------------------------------------------------------------
-