home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-02-21 | 122.0 KB | 3,023 lines |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- =======================================
- = =
- = MLIB(TM) v3.0 =
- = =
- = Mouse library for QuickBASIC =
- = =
- = 4.x =
- = =
- = and Visual Basic for MS-DOS =
- = =
- = =
- = Copyright (C) 1994 TERRY VENN =
- = =
- = All Rights Reserved =
- = =
- =======================================
- = =
- = TERRY VENN =
- = =
- = BOX 3A-10, D'ARCY, SK., =
- = =
- = S0L 0N0, CANADA. =
- = =
- = PHONE: 1-306-379-4505 =
- = =
- =======================================
-
-
-
- MLIB(TM) VERSION 3.0 COPYRIGHT (C) 1994 TERRY VENN
-
- ALL RIGHTS RESERVED
-
-
-
- =====================================================================
- = =
- = This software is a Shareware release and is provided at no charge =
- = to you for evaluation. =
- = =
- = YOU MAY USE THIS SOFTWARE ON A TRIAL BASIS PROVIDING YOU AGREE =
- = AND ADHERE TO THE FOLLOWING TERMS: =
- = =
- = 1. MLIB(TM) IS PROVIDED AS IS. =
- = =
- = 2. THE AUTHOR OF MLIB(TM) DISCLAIMS ALL WARRANTIES, =
- = EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE =
- = WARRANTIES OF MERCHANTABILITY AND OF FITNESS FOR ANY PURPOSE. =
- = =
- = 3. THE AUTHOR ASSUMES NO LIABILITIES FOR DAMAGES, CAUSED BY THE =
- = USE, MISUSE OR INABILITY TO USE MLIB(TM). =
- = =
- = 4. ANY FILES THAT YOU CREATE WITH THE AID OF THIS SHAREWARE =
- = VERSION AND CONTAIN MLIB(TM) LIBRARY ROUTINES MAY NOT BE =
- = DISTRUBUTED UNDER ANY CIRCUMSTANCES. =
- = =
- =====================================================================
-
-
-
- You may use this software on a 'try-before-you-buy' basis. At the end
- of this evaluation period you find it to be useful and wish to
- continue using the software, you are then expected to pay the
- registration fee.
-
- You may share copies of this software with others, provided that
- all the files pertaining to this software package are included
- with each copy and in their original condition.
-
- Distributors, refer to the VENDOR.DOC file.
-
-
- QuickBASIC and Visual Basic are trademarks of Microsoft Corporation.
-
- Microsoft, MS and MS-DOS are registered trademarks of Microsoft
- Corporation.
-
- IBM is a registered trademark of International Business Machines
- Corporation.
-
-
-
- MLIB v3.0 now offers more mouse power to MS-BASIC programmers than
- ever before, with its all new event-driven mouse interface. MLIB is
- now capable of working in the background (while your code is running)
- capturing all possible mouse events including double-clicks for all
- three buttons, pointer movement and even Shift, Crtl and Alt key
- events. These events are stored in a special buffer and can be
- removed at any time when needed. This means that while your program
- is performing some time-consuming task, mouse events are being
- captured and your program can respond to them when the task has been
- completed. No more missed clicks or double-clicks etc., frustrating
- the user.
-
- Another important feature, MLIB's event handling routines are simple
- to use. There are only two routines you actually need to work with;
- one installs and controls the internal handler, the other returns
- events from the mouse event buffer. A mouse toolkit (written in
- BASIC) is also provided with this library, to enhance mouse event
- handling even further.
-
- The use of the event-driven routines is optional. MLIB still provides
- a complete set of standard mouse controlling routines, that may be
- used on their own or, combined with the event-driven routines, its
- totally up to you on how they're used.
-
- MLIB is completely written in 8088 assembly, therefore the procedures
- are small and fast.
- -*-
-
-
- Print a Copy of This Manual:
-
- 1. Place the MLIB diskette into drive A.
- 2. Log onto drive A by typing: A: <Press Enter>
- 3. To begin printing type: COPY MLIB.DOC PRN <Press Enter>
-
- System and Software Requirements:
-
- An IBM PC/XT/AT/386 or compatible computer, plus a Microsoft
- compatible mouse and driver software, and Microsoft
- QuickBASIC 4.x or Visual Basic for DOS.
-
- Load the Correct Library:
-
- To run the sample programs or begin accessing the mouse
- routines, you must load the appropriate library for your
- particular version of BASIC. For example, to start the BASIC
- editor and load the right library:
-
- 1. If you are using QuickBASIC 4.0-4.5, type QB/L MLIBN.
-
- 2. If you are using Visual Basic for DOS, type VBDOS/L MLIBF.
-
- The 'N' appended to the library name identifies it as a near
- string support library. The 'F' appended to the library name
- identifies it as a far string support library.
-
-
-
- CONTENTS
- =====================================================================
-
- Event Handling Methods
-
- Initializing the Mouse ........................ 1
- Installing the Mouse Event Handler ............ 1
- Enabling the Event Handler .................... 2
- Disabling the Event Handler ................... 2
- Clearing the Event Buffer ..................... 2
- Events Captured by Default .................... 3
- Specifying Which Events Are Captured .......... 3
- Testing For Button Press Events ............... 5
- Testing For Button Release Events ............. 5
- Testing For Mouse Pointer Movement ............ 6
- Testing For Shift-State Key Events ............ 6
- Testing For Double-Click Events ............... 7
- Polling For Mouse Events ...................... 8
-
- Using Constants
-
- Mouse Event Handler Commands .................. 9
- Mouse Events .................................. 9
- Shift State Key Events ........................ 9
- Internal Data Offsets ......................... 10
-
- Event Handling Routines
-
- InMouseHandler ................................ 11
- InMouse ....................................... 12
- InMouseAddress ................................ 13
-
- Standard Routines
-
- InitPointer ................................... 14
- ChangePointer ................................. 15
- HidePointer ................................... 16
- ShowPointer ................................... 16
- ShowPtrM ...................................... 17
- GetButtonM .................................... 18
- GetPressM ..................................... 19
- GetReleaseM.................................... 20
- SetBoundM ..................................... 21
- SetHLimitM .................................... 22
- SetVLimitM .................................... 23
- SetPointer .................................... 24
- GetSpeedM ..................................... 25
- SetSpeedM ..................................... 26
- GetMotionM .................................... 27
- GetSizeM ...................................... 28
- SaveStateM .................................... 29
- RestoreStateM ................................. 30
- Sample Pointer Shapes ......................... 31
-
- ---------------------------------------------------------------------
-
-
-
- CONTENTS continued...
- =====================================================================
-
- Mouse Toolkit Routines
-
- InMouseState .................................. 32
- GetEventsPending .............................. 32
- GetEventMask .................................. 33
- SetEventMask .................................. 34
- GetDblClkSettings ............................. 35
- SetDblClkSettings ............................. 36
- InMouseSave ................................... 37
- InMouseRestore ................................ 37
-
- Additional Routines
-
- CviBin ........................................ 38
- CvsBin ........................................ 38
- GetWord ....................................... 39
- PutWord ....................................... 39
- InWinM ........................................ 40
-
- Miscellaneous Information
-
- Discontinued Routines ......................... 41
- MLIB and Visual Basic Forms ................... 41
- MLIB Versus the Basic Editor .................. 42
- How To Contact the Author ..................... 43
- Registration Fee .............................. 44
- How To Register ............................... 44
- Registered Users Will Receive ................. 44
-
- ---------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- =====================================================================
-
-
-
-
- Event Handling Methods
-
-
-
-
- =====================================================================
-
-
-
- Event Handling Methods
- =====================================================================
- This section provides all the necessary information needed to begin
- accessing the mouse and handling all the different mouse events. All
- of the following code examples make use of symbolic constant names
- (defined in the MLIB.BI include file) for easier reading. See: Using
- Constants.
-
-
- Initializing the Mouse:
-
- Before any of the mouse routines, including the standard
- mouse routines, can be accessed, the mouse driver and the
- library must be initialized. The Buttons% argument returns
- the number of buttons on the mouse; if it returns zero, there
- is no driver installed. Note, all the mouse routines can be
- safely called whether a mouse driver is installed or not.
-
- IMPORTANT: For proper operation always include the MLIB.BI
- file near the beginning of your code prior to making any
- mouse calls.
-
- ' $INCLUDE: 'MLIB.BI'
-
- ' Initialize the mouse and library.
- CALL InitPointer(Buttons%)
-
-
- Installing the Mouse Event Handler:
-
- To begin capturing mouse events the event handler must be
- installed. Installing the handler does the following:
-
- - Links up with the mouse driver.
- - Places the mouse pointer on the screen.
- - Begins capturing events when they occur.
- - Stuffs captured events in the event buffer.
-
- By default the event handler captures all button events,
- including double-click and shift-state key events. Use the
- mouse toolkit to alter these settings.
-
- NOTE: You only need to install the handler once in your
- program. Disabling the handler just forces it to quit
- capturing events. The handler automatically removes itself
- when your program ends (normal or abnormal termination).
-
- ' Install the event handler.
- CALL InMouseHandler(EventInstall)
-
- ---------------------------------------------------------------------
- Continued...
-
-
- Page 1
-
-
-
- Event Handling Methods
- =====================================================================
-
- Enabling the Event Handler:
-
- Once the event handler has been installed, it remains enabled
- (active) until you explicitly call and disable it.
-
- Enabling the handler places the mouse pointer on the screen,
- begins responding to mouse events and allows events to be
- removed from the event buffer
-
- ' Enable event handler.
- CALL InMouseHandler(EventEnable)
-
- Disabling the Event Handler:
-
- Disabling the handler removes the mouse pointer from the
- screen, prevents mouse events from being removed from the
- event buffer and ignores capturing any mouse events.
-
- ' Disable event handler.
- CALL InMouseHandler(EventDisable)
-
- Clearing the Event Buffer:
-
- Clearing the event buffer removes all mouse events currently
- pending in the buffer.
-
- NOTE: The handler must be enabled before it will allow the
- buffer to be cleared.
-
- IMPORTANT: Make sure that you are not inside a loop that
- relies on a button release event to exit. For example:
-
- Clearing the buffer here would cause a continuous loop if the
- left mouse button has already been released and the event is
- waiting in the buffer. For the loop to break, the user would
- have to press and release the left button again.
-
- ' Clear the event buffer.
- CALL InMouseHandler(ClearBuffer)
-
- DO
- ' Poll for mouse events.
- MouseEvent% = InMouse(MouseX%, MouseY%)
-
- LOOP UNTIL MouseEvent% AND LButtonUp
-
- ---------------------------------------------------------------------
- Continued...
-
-
-
- Page 2
-
-
-
- Event Handling Methods
- =====================================================================
-
- Events Captured by Default:
-
- The event handler captures the following events by default:
-
- - Left button presses and releases.
- - Right button presses and releases.
- - Center button presses and releases.
- - Left button double-clicks.
- - Right button double-clicks.
- - Center button double-clicks.
- - Shift key pressed during mouse event.
- - Ctrl key pressed during mouse event.
- - Alt key pressed during mouse event.
-
-
- Specifying Which Events Are Captured:
-
- Capturing events in this section refers to mouse events the
- event handler traps and stores in the event buffer.
-
- Event mask refers to a two byte bit-field the event handler
- uses to determine which events are captured.
-
- The following table shows which mouse events the user can
- specifically command the event handler to capture.
-
- Event mask bit-field: Captures (when set): Value:
- ===================== ============================ ==========
- 00000000 00000000---- Mouse pointer movement 1
- -------- -|||||`----- Left button presses 2
- | ||||`------ Left button releases 4
- | |||`------- Right button presses 8
- | ||`-------- Right button releases 16
- | |`--------- Center button presses 32
- | `---------- Center button releases 64
- `---------------- Unused ....
- -------------------------------------------------------------
-
- NOTE: To prevent double-click events from being returned, set
- the double-click speed setting to zero. See the mouse toolkit
- routine: SetDblClkSettings in this manual. It is impossible to
- stop shift-state key events from being returned. Just ignore
- these events if they are not needed.
-
- ---------------------------------------------------------------------
- Continued...
-
-
-
-
-
- Page 3
-
-
-
- Event Handling Methods
- =====================================================================
-
- Specifying Which Events Are Captured: (continued...)
-
- The handler uses this mask by default: 00000000 01111110. If
- your program does not require that any mouse movement events
- be trapped, then it would not be necessary to change the
- default settings. To build your own mask is simple, for
- example we will start with a blank mask:
-
- 00000000 00000000
-
- add pointer movement by OR-ing with the value 1, the mask
- would now look like this:
-
- 00000000 00000001
-
- now add left button presses to the mask by OR-ing with the
- value 2:
-
- 00000000 00000011
-
- finally add left button releases by OR-ing with the value 4,
-
- NewMask% = 00000000 00000111
-
- the finished mask would now total (4+2+1) 7. Now we could
- call the SetEventMask() routine and pass it our new mask and
- the event handler would start trapping these events and
- stuff them in the buffer (if the handler is enabled).
-
- Now if we wanted to stop trapping mouse movement, all we need
- to do is use the NOT operator like this:
-
- NewMask% = NewMask% AND NOT 1
-
- then call SetEventMask(NewMask%), the handler will now quit
- trapping mouse movement.
-
- The following code fragment requires that left button plus
- pointer movement events be trapped and placed in the event
- buffer. The use of the mouse toolkit routines are required
- to do this task.
-
- ' Save current mask.
- CALL GetEventMask(OldMask%)
-
- ---------------------------------------------------------------------
- Continued...
-
-
-
-
- Page 4
-
-
-
- Event Handling Methods
- =====================================================================
-
- Specifying Which Events Are Captured: (continued...)
-
- ' Create a new event mask to trap left button and mouse
- ' movement events.
- NewMask% = NewMask% OR LButtonDown OR LButtonUp OR MouseMoved
-
- ' Tell the event handler to start trapping these events.
- CALL SetEventMask(NewMask%)
- .
- . Make use of the captured events here, and when task is
- . completed, restore mask back to the way it was before
- . we altered it.
-
- ' Restore original event mask.
- CALL SetEventMask(OldMask%)
-
-
- Testing For Button Press Events:
-
- The following code fragment shows how to test for button
- press events:
-
- ' Pull an event from the event buffer.
- MouseEvent% = InMouse(MouseX%, MouseY%)
-
- IF MouseEvent% AND LButtonDown THEN
-
- ' Left button was pressed.
-
- ELSEIF MouseEvent% AND RButtonDown THEN
-
- ' Right button was pressed.
-
- ELSEIF MouseEvent% AND CButtonDown THEN
-
- ' Center button was pressed.
-
- END IF
-
-
- Testing For Button Release Events:
-
- The following code fragment shows how to test for button
- release events:
-
- ---------------------------------------------------------------------
- Continued...
-
-
-
-
- Page 5
-
-
-
- Event Handling Methods
- =====================================================================
-
- Testing For Button Release Events: (continued...)
-
- ' Pull an event from the event buffer.
- MouseEvent% = InMouse(MouseX%, MouseY%)
-
- IF MouseEvent% AND LButtonUp THEN
-
- ' Left button was released.
-
- ELSEIF MouseEvent% AND RButtonUp THEN
-
- ' Right button was released.
-
- ELSEIF MouseEvent% AND CButtonUp THEN
-
- ' Center button was released.
-
- END IF
-
-
- Testing For Mouse Pointer Movement:
-
- The following code fragment shows how to test for mouse
- movement.
-
- ' Pull an event from the event buffer.
- MouseEvent% = InMouse(MouseX%, MouseY%)
-
- IF MouseEvent% AND MouseMoved THEN
-
- ' The pointer moved.
-
- END IF
-
- IF MouseEvent% AND LButtonDown OR (continued on next line...)
- MouseEvent% AND MouseMoved THEN
-
- ' Left button was pressed or the pointer moved.
-
- END IF
-
-
- Testing For Shift-State Key Events:
-
- The following code fragment shows how to test for shift-
- state key events:
-
- ---------------------------------------------------------------------
- Continued...
-
-
- Page 6
-
-
-
- Event Handling Methods
- =====================================================================
-
- Testing For Shift-State Key Events: (continued...)
-
- ' Pull an event from the event buffer.
- MouseEvent% = InMouse(MouseX%, MouseY%)
-
- IF MouseEvent% AND ShiftKey THEN
-
- ' Shift key was down when mouse event occurred.
-
- ELSEIF MouseEvent% AND CtrlKey THEN
-
- ' Ctrl key was down when mouse event occurred.
-
- ELSEIF MouseEvent% AND AltKey THEN
-
- ' Alt key was down when mouse event occurred.
-
- END IF
-
-
- Testing For Double-Click Events:
-
- A double-click event is always returned in this order;
- ButtonDown, ButtonUp, ButtonDown plus ButtonDblClk and a
- final ButtonUp when user releases the button.
-
- The following code fragment shows how to test for double-
- clicks.
-
- ' Pull an event from the event buffer.
- MouseEvent% = InMouse(MouseX%, MouseY%)
-
- IF MouseEvent% AND LButtonDblClk THEN
-
- ' Left button was double-clicked.
-
- ELSEIF MouseEvent% AND RButtonDblClk THEN
-
- ' Right button was double-clicked.
-
- ELSEIF MouseEvent% AND CButtonDblClk THEN
-
- ' Center button was double-clicked.
-
- END IF
-
- ---------------------------------------------------------------------
- Continued...
-
-
-
- Page 7
-
-
-
- Event Handling Methods
- =====================================================================
-
- Polling For Mouse Events:
-
- The following sample is an empty code shell that shows how
- you could poll for mouse and keyboard events. It assumes the
- mouse event handler's default settings are used.
-
- See: InMouseHandler, for the default settings.
-
- NOTE: The mouse position is always returned (unless of course
- there is no mouse installed) in MouseX% and MouseY%. If the
- event buffer is empty the current pointer position is
- returned. If an event is returned (if MouseEvent% returns a
- value) from the buffer, then the coordinates reflect the
- position of the pointer WHEN the mouse event occurred.
-
- DO
- DO ' Poll for a mouse event.
- MouseEvent% = InMouse(MouseX%, MouseY%)
-
- KeyPress$ = INKEY$: KeyEvent% = LEN(KeyPress$)
-
- LOOP UNTIL MouseEvent% OR KeyEvent%
-
- IF KeyEvent% THEN ' Branch here for key presses.
-
- ' Respond to left button events only. You could add code
- ' to test for the right and center button plus shift-state
- ' events here also if needed.
- IF MouseEvent% THEN
-
- IF MouseEvent% AND LButtonDown THEN
- ' Branch for a left button press.
- END IF
-
- IF MouseEvent% AND LButtonUp THEN
- ' Branch for a left button release.
- END IF
-
- IF MouseEvent% AND LButtonDblClk THEN
- ' Branch for a left button double-click.
- END IF
-
- END IF
-
- LOOP UNTIL KeyPress$ = CHR$(27) ' The Esc key exits.
-
- ---------------------------------------------------------------------
-
-
-
-
- Page 8
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- =====================================================================
-
-
-
-
- Using Constants
-
-
-
-
- =====================================================================
-
-
-
- Using Constants
- =====================================================================
-
- MLIB comes with an include file called MLIB.BI. It contains all the
- constant definitions needed to control the event handling routines
- and masking values needed to test for events. Using these constants
- will make your code much easier to read. If your program is large,
- you may need to edit the MLIB.BI file and remove unused definitions,
- thus increasing the amount of available memory.
-
- Mouse Event Handler Commands:
-
- Use these constants to control the mouse event handler.
-
- Constant Name: Value: Performs This Task:
- ==================== ====== =================================
- EventInstall 1 Installs handler - shows pointer
- EventEnable 2 Enables handler - shows pointer
- EventDisable 4 Disables handler - hides pointer
- ClearBuffer 8 Clears event buffer
- -------------------------------------------------------------
-
- Mouse Events:
-
- Use these constants as a mask when testing for mouse events.
-
- Constant Name: Value: Represents:
- ==================== ====== =================================
- MouseMoved 1 Mouse pointer moved
- LButtonDown 2 Left button pressed
- LButtonUp 4 Left button released
- RButtonDown 8 Right button pressed
- RButtonUp 16 Right button released
- CButtonDown 32 Center button pressed
- CButtonUp 64 Center button released
- LButtonDblClk 128 Left button double-click
- RButtonDblClk 256 Right button double-click
- CButtonDblClk 512 Center button double-click
- -------------------------------------------------------------
-
- Shift-State Key Events:
-
- Use these constants as a mask when testing for shift events.
-
- Constant Name: Value: Represents:
- ==================== ====== =================================
- ShiftKey 1024 Shift key down
- CtrlKey 2048 Ctrl key down
- AltKey 4096 Alt key down
- -------------------------------------------------------------
-
- ---------------------------------------------------------------------
- Continued...
-
- Page 9
-
-
-
- Using Constants
- =====================================================================
- Internal Data Offsets:
-
- The mouse toolkit makes use of these constants as an offset
- pointer to certain internal data. Each constant value is
- relative to the first byte in the mouse event handler's data
- storage area.
-
- Constant Name: Value: Points To The:
- ==================== ====== =================================
- InMouseStateOff 28 Handler status flag
- EventMaskOff 30 Mouse event mask word
- ClickSOff 32 Double-click speed setting
- ClickWOff 34 Double-click width setting
- ClickHOff 36 Double-click height setting
- HeadPtrOff 38 Head pointer position
- TailPtrOff 40 Tail pointer position
- BufferOff 42 First byte in the event buffer
- -------------------------------------------------------------
-
- ---------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 10
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- =====================================================================
-
-
-
-
- Event Handling Routines
-
-
-
-
- =====================================================================
-
-
-
- InMouseHandler
- =====================================================================
-
- Controls the mouse event handler.
-
- DECLARE SUB InMouseHandler(BYVAL Action%)
-
- Syntax: CALL InMouseHandler(Action%)
-
- Action% Commands the mouse event handler to perform a
- specific task.
-
- Command values: 1 - install
- 2 - enable
- 4 - disable
- 8 - clear buffer
-
- Example: For a working example see: MLIBSAM6.BAS
-
- Comments:
-
- The mouse event handler is simular to a TSR program, it must
- be installed before it can perform any tasks. Upon
- installation, the mouse pointer is placed on the screen, and
- the handler immediately becomes active responding to mouse
- events. By default the handler captures left, right, and
- center mouse button events, including double-clicks and
- shift-state key events. The captured events are stored in the
- event buffer, simular to way keyboard data is stored in the
- type-ahead buffer. The event buffer can hold a maximum of
- eight mouse events.
-
- IMPORTANT: The mouse driver and MLIB MUST be initialized
- before installing the mouse event handler.
-
- Disabling the handler removes the pointer from the screen and
- temporarily suspends events from being captured until it is
- once again enabled, in which case the pointer is placed back
- on the screen. Clearing the event buffer removes all events
- that are currently pending, and also clears internal data.
-
- NOTE: When the handler is disabled, events cannot be returned
- from the mouse event buffer. Events will be returned
- when the handler is re-enabled.
-
- See Also: InitPointer, InMouse, Using Constants
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
- Page 11
-
-
-
- InMouse
- =====================================================================
-
- Returns mouse events from the mouse event buffer.
-
- DECLARE FUNCTION InMouse% (MouseX%, MouseY%)
-
- Syntax: MouseEvent% = InMouse(MouseX%, MouseY%)
-
- MouseEvent% An argument that is a bit-field with bits
- corresponding to captured mouse and shift-state
- events. See the Event bit-field table below.
-
- MouseX% Returns the horizontal position (in pixels) of
- the mouse pointer.
-
- MouseY% Returns the vertical position (in pixels) of
- the mouse pointer.
-
- Example: For a working example see: MLIBSAM6.BAS
-
- Comments:
-
- IMPORTANT: When a mouse event is returned, MouseX and MouseY
- return the position of the pointer WHEN the event occurred,
- NOT the current position. The current pointer position is
- returned ONLY when the mouse event buffer is empty.
-
- The following table shows all possible mouse events and
- corresponding bits in the bit-field.
-
- Event bit-field: Represents (when set): Bit: Value:
- ==================== =========================== ===== ======
- 00000000 00000000--- Mouse pointer moved 0 1
- ---||||| ||||||`---- Left button pressed 1 2
- | ||||| |||||`----- Left button released 2 4
- | ||||| ||||`------ Right button pressed 3 8
- | ||||| |||`------- Right button released 4 16
- | ||||| ||`-------- Center button pressed 5 32
- | ||||| |`--------- Center button released 6 64
- | ||||| `---------- Left button double-click 7 128
- | ||||`------------ Right button double-click 8 256
- | |||`------------- Center button double-click 9 512
- | ||`-------------- Shift key down 10 1024
- | |`--------------- Ctrl key down 11 2048
- | `---------------- Alt key down 12 4096
- `------------------ Unused 13-15 ....
- -------------------------------------------------------------
-
- See Also: InMouseHandler, Using Constants
-
- ---------------------------------------------------------------------
- Assembly function
-
- Page 12
-
-
-
- InMouseAddress
- =====================================================================
-
- Returns an address to the mouse event handler's internal data area.
-
- Use in conjunction with: GetWord, PutWord
-
- DECLARE FUNCTION InMouseAddress% (Offset%)
-
- Syntax: Segment% = InMouseAddress(Offset%)
-
- Segment% Returns the segment part of address.
-
- Offset% Returns the offset part of address.
-
- Example:
-
- Segment% = InMouseAddress(Offset%) ' Get address.
-
- DEF SEG = Segment% ' Change to the segment.
-
- Byte% = PEEK(Offset%) ' Byte now holds the value
- ' of the first byte in the
- DEF SEG ' handler's data block.
-
- Comments:
-
- The purpose of this function is to keep the library as small
- as possible by eliminating code needed to alter the internal
- default settings of the event handler; and still offer the
- BASIC programmer a way to change these settings if needed.
-
- To change the default settings, load the mouse toolkit
- (MLIBTOOL.BAS) along with your program and call the
- appropriate routines.
-
- NOTE: The mouse event handler does not need to be installed
- to use this procedure.
-
- For a working example see: MLIBTOOL.BAS
-
- See Also: Mouse Toolkit Routines, GetWord, PutWord, Using Constants
-
- ---------------------------------------------------------------------
- Assembly function
-
-
-
-
-
-
-
-
-
- Page 13
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- =====================================================================
-
-
-
-
- Standard Routines
-
-
-
-
- =====================================================================
-
-
-
- InitPointer
- =====================================================================
-
- Initialize the mouse driver and the MLIB library.
-
- DECLARE SUB InitPointer(Buttons%)
-
- Syntax: CALL InitPointer(Buttons%)
-
- Buttons% Returns the number of buttons on the mouse. If a
- mouse driver is not detected or there is no mouse
- attached to the system, then the Buttons% argument
- returns a zero.
-
- Example:
-
- CALL InitPointer(Buttons%)
-
- IF Buttons% THEN
-
- PRINT "This mouse has "; Buttons%; " buttons."
-
- ELSE
-
- PRINT "Unable to detect a mouse."
-
- END IF
-
- Comments:
-
- IMPORTANT: This routine must be called before you can access
- any of the internal mouse routines, including both the
- standard and the event handling routines. You should also
- call this routine immediately after a screen-mode change so
- the mouse driver can adjust for the new mode setting.
-
- Your program can safely call any routines in this library
- whether a mouse driver is installed or not.
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 14
-
-
-
- ChangePointer
- =====================================================================
-
- Change the shape of the mouse pointer (graphic modes only).
-
- DECLARE SUB ChangePointer(Shape$, HotX%, HotY%)
-
- Syntax: CALL ChangePointer(Shape$, HotX%, HotY%)
-
- Shape$ A 64 byte string, consisting of two 32 byte sections.
- The first 32 bytes is the screen mask which is ANDed
- on the screen. The last half containing the cursor
- mask is then XORed over this. A color cursor (SOLID)
- can have two colors, white or black, where a non-color
- cursor (TRANS) just inverts with the colored pixels it
- passes over.
-
- HotX% Horizontal hot spot value ranging from 0 - 15.
-
- HotY% Vertical hot spot value ranging from 0 - 15.
-
- Example:
-
- HotX% = 0
- ' Upper left corner of new image
- HotY% = 0
-
- Shape$ = Arrow$ ' String containing the new image.
-
- CALL ChangePointer(Shape$, HotX%, HotY%)
-
- Comments:
-
- The mouse driver uses the hot spot coordinates to determine
- the location of the pointer.
-
- For a working example see: MLIBVIEW.BAS
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 15
-
-
-
- HidePointer
- =====================================================================
-
- Remove the mouse pointer from the screen.
-
- Use in conjunction with: ShowPointer
-
- DECLARE SUB HidePointer
-
- Syntax: CALL HidePointer
-
- Example:
-
- CALL HidePointer ' Remove pointer before printing.
-
- PRINT "A line of text."
-
- CALL ShowPointer ' Restore after the task has been completed.
-
- Comments:
-
- You must turn off the pointer before doing any drawing or
- printing on the screen; this will prevent the pointer from
- being overwritten. It should also be noted that the mouse
- driver increments a counter each time the pointer is turned
- off, and decrements that count for each call to turn it back
- on. This count must equal zero before the driver will turn
- the pointer back on. For example; if HidePointer() is called
- 3 times, then ShowPointer() must also be called 3 times
- before the pointer will actually become visible.
-
- See Also: ShowPointer, ShowPtrM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
- ShowPointer
- =====================================================================
-
- Display the mouse pointer on the screen.
-
- Use in conjunction with: HidePointer
-
- DECLARE SUB ShowPointer
-
- Syntax: CALL ShowPointer
-
- See Also: HidePointer, ShowPtrM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
- Page 16
-
-
-
- ShowPtrM
- =====================================================================
-
- Restore the mouse pointer on the screen.
-
- Use in conjunction with: GetSizeM
-
- DECLARE FUNCTION ShowPtrM%(Buffer$)
-
- Syntax: ErrNum% = ShowPtrM%(Buffer$)
-
- ErrNum% If successful a value of 0 will be returned.
-
- If unsuccessful a value of -1 will be returned
- (Buffer$ was of insufficient size).
-
- Buffer$ ShowPtrM% needs a working space of at least twice
- the size of the mouse driver's environment.
-
- Example:
-
- Size% = GetSizeM% ' Amount of memory needed to hold
- ' the mouse driver's environment.
-
- Buffer$ = SPACE$(Size% * 2) ' Pad buffer with spaces.
-
- ErrNum% = ShowPtrM%(Buffer$)' Restore pointer.
-
- Buffer$ = "" ' Release memory.
-
- Comments:
-
- The purpose of this function is to explicitly show the
- pointer on the screen.
-
- If the mouse pointer has been removed from the screen an
- unknown number of times, calling ShowPointer() once would
- fail to re-show the pointer. For example: if the pointer has
- been hidden 3 times, then the pointer would have to be shown
- 3 times before it would actually become visible.
-
- NOTE: This routine requires a greater amount of time to
- accomplish its task than ShowPointer() needs to show the
- pointer only once.
-
- See Also: GetSizeM, ShowPointer
-
- ---------------------------------------------------------------------
- Assembly function
-
-
-
-
-
- Page 17
-
-
-
- GetButtonM
- =====================================================================
-
- Get the current horizontal and vertical positon of the mouse pointer
- plus mouse button status.
-
- DECLARE SUB GetButtonM(Button%, MouseX%, MouseY%)
-
- Syntax: CALL GetButtonM(Button%, MouseX%, MouseY%)
-
- Button% Returns a bit-field with bits set that identify
- which button(s) are currently pressed.
-
- MouseX% Returns the current horizontal position of the
- mouse pointer (in pixels).
-
- MouseY% Returns the current vertical position of the
- mouse pointer (in pixels).
-
- Example:
-
- SCREEN 0 ' Convert the virtual mouse screen coordinates
- ' to BASIC's row/column format, in text mode.
- DO ' Using a character block size of 8 X 8.
-
- CALL GetButtonM(Button%, X%, Y%)
-
- Row% = (Y% \ 8) + 1
- Col% = (X% \ 8) + 1
-
- LOCATE 1: PRINT Row%; " X "; Col%
-
- IF Button% AND 1 THEN ' The left button is down.
-
- IF Button% AND 2 THEN ' The right button is down.
-
- IF Button% AND 4 THEN ' The center button is down.
-
- LOOP UNTIL LEN(INKEY$)
-
- Comments:
-
- Button bit-field: Represents (when set): Value:
- ===================== ======================= =============
- 00000000 00000000---- Left button pressed 1
- |`----- Right button pressed 2
- `------ Center button pressed 4
- -------------------------------------------------------------
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
- Page 18
-
-
-
- GetPressM
- =====================================================================
-
- Get specific button press information.
-
- DECLARE SUB GetPressM(Button%, Stat%, Count%, MouseX%, MouseY%)
-
- Syntax: CALL GetPressM(Button%, Stat%, Count%, MouseX%, MouseY%)
-
- Button% Specifies which mouse button is checked and for
- which information is to be returned. 1 checks the
- left button, 2 and 3 check the right and center
- buttons respectively.
-
- Stat% Returns a bit-field containing the current button
- status. A value of 1, 2 or 4 (or a combination of)
- indicates the left, right or center button is
- currently being pressed, respectively.
-
- Count% Returns the number of times the requested button
- has been pressed since last called.
-
- MouseX% Returns the horizontal position (in pixels) of the
- mouse pointer when the button was last pressed.
-
- MouseY% Returns the vertical position (in pixels) of the
- mouse pointer when the button was last pressed.
-
- Example:
-
- Button% = 1 ' Check the left button.
-
- CALL GetPressM(Button%, Stat%, Count%, MouseX%, MouseY%)
-
- IF Count% > 1 THEN
- PRINT "Left button has been pressed: "; Count%; " times"
- END IF
-
- Comments:
-
- NOTE: The values returned by MouseX% and MouseY% refer to the
- location of the pointer WHEN the mouse button was pressed,
- NOT the current location. The button count is automatically
- reset to zero each time this routine is called.
-
- See Also: GetReleaseM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
- Page 19
-
-
-
- GetReleaseM
- =====================================================================
-
- Get specific button release information.
-
- DECLARE SUB GetReleaseM(Button%, Stat%, Count%, MouseX%, MouseY%)
-
- Syntax: CALL GetReleaseM(Button%, Stat%, Count%, MouseX%, MouseY%)
-
- Button% Specifies which mouse button is checked and for
- which information is to be returned. 1 checks the
- left button, 2 and 3 check the right and center
- buttons respectively.
-
- Stat% Returns a bit-field containing the current button
- status. A value of 1, 2 or 4 (or a combination of)
- indicates the left, right or center button is
- currently being pressed, respectively.
-
- Count% Returns the number of times the requested button
- has been released since last called.
-
- MouseX% Returns the horizontal position (in pixels) of the
- mouse pointer when the button was last released.
-
- MouseY% Returns the vertical position (in pixels) of the
- mouse pointer when the button was last released.
-
- Example:
-
- Button% = 1 ' Check the left button.
-
- CALL GetReleaseM(Button%, Stat%, Count%, MouseX%, MouseY%)
-
- IF Count% > 1 THEN
- PRINT "Left button has been released: "; Count%; " times"
- END IF
-
- Comments:
-
- NOTE: The values returned by MouseX% and MouseY% refer to the
- location of the pointer WHEN the mouse button was released,
- NOT the current location. The button count is automatically
- reset to zero each time this routine is called.
-
- See Also: GetPressM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
- Page 20
-
-
-
- SetBoundM
- =====================================================================
-
- Confine pointer movement to a specified area on the screen.
-
- DECLARE SUB SetBoundM(x1%, y1%, x2%, y2%)
-
- Syntax: CALL SetBoundM(x1%, y1%, x2%, y2%)
-
- x1%, x2% Left and right boundaries (in pixels).
-
- y1%, y2% Top and bottom boundaries (in pixels).
-
- Example:
-
- ' Limit pointer to an area starting in the upper left corner
- ' of the screen, 100 pixels wide by 100 pixels high.
-
- CALL SetBoundM(0, 0, 100, 100)
-
- Comments:
-
- This routine eliminates the need of calling both SetHLimit()
- and SetVLimit() to confine the pointer to an enclosed area.
-
- See Also: SetHLimitM, SetVLimitM.
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 21
-
-
-
- SetHLimitM
- =====================================================================
-
- Specify a left and right boundary in which the horizontal movement of
- the mouse pointer will be confined.
-
- Use in conjunction with: SetVLimitM
-
- DECLARE SUB SetHLimitM(X%, Y%)
-
- Syntax: CALL SetHLimitM(X%, Y%)
-
- X% Minimum left limit in pixels.
-
- Y% Maximum right limit in pixels.
-
- Example:
-
- X1% = 0 ' Create a window in which the pointer will be
- Y1% = 100 ' confined.
- X2% = 0
- Y2% = 100
-
- CALL SetHLimitM(X1%, Y1%)
-
- CALL SetVLimitM(X2%, Y2%)
-
- Comments:
-
- If the left value is greater than the right value, this
- routine will exchange the two. The pointer will then be
- displayed within these two boundaries.
-
- See Also: SetVLimitM, SetBoundM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 22
-
-
-
- SetVLimitM
- =====================================================================
-
- Specify an upper and lower boundary in which the vertical movement of
- the mouse pointer will be confined.
-
- Use in conjunction with: SetHLimitM
-
- DECLARE SUB SetVLimitM(X%, Y%)
-
- Syntax: CALL SetVLimitM(X%, Y%)
-
- X% Minimum upper limit in pixels.
-
- Y% Maximum lower limit in pixels.
-
- Example:
-
- X1% = 0 ' Create a window in which the pointer will be
- Y1% = 100 ' confined.
- X2% = 0
- Y2% = 100
-
- CALL SetHLimitM(X1%, Y1%)
-
- CALL SetVLimitM(X2%, Y2%)
-
- Comments:
-
- If the upper value is greater than the lower value, this
- routine will exchange the two. The pointer will then be
- displayed within these two boundaries.
-
- See Also: SetHLimitM, SetBoundM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 23
-
-
-
- SetPointer
- =====================================================================
-
- Display the mouse pointer at a new location.
-
- DECLARE SUB SetPointer(X%, Y%)
-
- Syntax: CALL SetPointer(X%, Y%)
-
- X% New horizontal position, in pixels.
-
- Y% New vertical position, in pixels.
-
- Example:
-
- X% = 0 ' Place the pointer in the upper left corner of the
- ' screen.
- Y% = 0
-
- CALL SetPointer(X%, Y%)
-
- Comments:
-
- If X% or Y% are outside of any defined boundary, such as off
- the screen, the mouse driver will automatically place the
- pointer to the nearest legal position within this boundary.
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 24
-
-
-
- GetSpeedM
- =====================================================================
-
- Get the rate settings at which the pointer travels across the screen.
-
- Use in conjunction with: SetSpeedM
-
- DECLARE SUB CALL GetSpeedM(H%, V%, D%)
-
- Syntax: CALL GetSpeedM(H%, V%, D%)
-
- H% Returns the current horizontal value.
-
- V% Returns the current vertical value.
-
- D% Returns double speed threshold value.
-
- Example:
-
- ' Get and save the current sensitivity state of the mouse.
- ' Upon ending your program, pass these values to the routine
- ' SetSpeedM(), which will restore the settings back to their
- ' original state.
-
- ' Program startup.
-
- CALL GetSpeedM(SaveH%, SaveV%, SaveD%) ' Save old settings.
- CALL SetSpeedM(50, 50, 50) ' New setting for your
- ' program's use.
- ' Program code.
-
- CALL SetSpeedM(SaveH%, SaveV%, SaveD%) ' Restore setting.
-
- ' End of program.
-
- Comments:
-
- Mouse sensitivity is defined as how far the pointer moves
- per actual movement of the mouse itself. The higher the
- values in X%, Y%, the greater the sensitivity (or rate of
- travel).
-
- See Also: SetSpeedM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
- Page 25
-
-
-
- SetSpeedM
- =====================================================================
-
- Set the rate at which the pointer travels across the screen.
-
- Use in conjunction with: GetSpeedM
-
- DECLARE SUB CALL SetSpeedM(H%, V%, D%)
-
- Syntax: CALL SetSpeedM(H%, V%, D%)
-
- H% New horizontal value (1 - 100).
-
- V% New vertical value (1 - 100).
-
- D% New double speed threshold (1 - 100).
-
- Example:
-
- ' Get and save the current sensitivity state of the mouse.
- ' Upon ending your program, pass these values to the routine
- ' SetSpeedM(), which will restore the settings back to their
- ' original state.
-
- ' Program startup.
-
- CALL GetSpeedM(SaveH%, SaveV%, SaveD%) ' Save old settings.
- CALL SetSpeedM(50, 50, 50) ' New setting for your
- ' program's use.
- ' Program code.
-
- CALL SetSpeedM(SaveH%, SaveV%, SaveD%) ' Restore setting.
-
- ' End of program.
-
- Comments:
-
- Mouse sensitivity is defined as how far the pointer moves
- per actual movement of the mouse itself. The higher the
- values in X%, Y%, the greater the sensitivity (or rate of
- travel).
-
- See Also: GetSpeedM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
- Page 26
-
-
-
- GetMotionM
- =====================================================================
-
- Get the mouse pointer's direction of travel.
-
- DECLARE SUB GetMotionM(MouseX%, MouseY%)
-
- Syntax: CALL GetMotionM(MouseX%, MouseY%)
-
- MouseX% Returns the horizontal value.
-
- MouseY% Returns the vertical value.
-
- Example:
-
- DO
-
- CALL GetMotionM(MouseX%, MouseY%)
-
- Direction$ = ""
-
- IF MouseX% > 0 THEN Direction$ = "Right" ' If positive.
- IF MouseX% < 0 THEN Direction$ = "Left " ' If negative.
- IF MouseY% > 0 THEN Direction$ = "Down " ' If positive.
- IF MouseY% < 0 THEN Direction$ = "Up " ' If negative.
-
- IF LEN(Direction$) THEN
-
- LOCATE 5
-
- PRINT Direction$
-
- END IF
-
- LOOP UNTIL LEN(INKEY$)
-
- Comments:
-
- The values returned will range from -32768 to 32768. Positive
- values show right or downward movement, and negative values
- show left or upward movement.
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
-
-
- Page 27
-
-
-
- GetSizeM
- =====================================================================
-
- Get the size the mouse driver's environment.
-
- Use in conjunction with: ShowPtrM%, SaveStateM
-
- DECLARE FUNCTION GetSizeM%
-
- Syntax: Size% = GetSizeM%
-
- Size% Returns the size of the mouse driver's environment
- (in bytes).
-
- Example:
-
- Size% = GetSizeM% ' Amount of memory needed to hold the
- ' mouse driver's environment.
-
- Buffer$ = SPACE$(Size% * 2) ' Pad buffer with spaces.
-
- ErrNum% = ShowPtrM%(Buffer$)
-
- Buffer$ = "" ' Release memory.
-
- Comments:
-
- Use this function to determine buffer size needed by both
- ShowPtrM% () and SaveStateM().
-
- See Also: ShowPtrM%, RestoreStateM, SaveStateM
-
- ---------------------------------------------------------------------
- Assembly function
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 28
-
-
-
- SaveStateM
- =====================================================================
-
- Save the mouse driver's environment.
-
- Use in conjunction with: GetSizeM, RestoreStateM
-
- DECLARE SUB SaveStateM(Buffer$, ErrNum%)
-
- Syntax: CALL SaveStateM(Buffer$, ErrNum%)
-
- Buffer$ Buffer in which the mouse driver's environment
- will be stored.
-
- ErrNum% Returns a -1, if Buffer$ is not large enough to
- hold the mouse environment.
-
- Example:
-
- ' Amount of memory needed to hold the mouse state.
- Size% = GetSizeM%
-
- Buffer$ = SPACE$(Size%) ' Pad buffer with spaces.
-
- CALL SaveStateM(Buffer$, ErrNum%) ' Save mouse state.
-
- CALL HidePointer
-
- SHELL"XXXX" ' Pass control.
-
- CALL ShowPointer
-
- CALL RestoreStateM(Buffer$, ErrNum%) ' Restore state.
-
- Comments:
-
- If your program needs to temporarily pass control to another
- program or procedure that also uses the mouse and where the
- mouse state may be altered (such as a video mode change), use
- GetSizeM% () along with this subroutine, to save the mouse
- state first before passing control. When your program has
- regained control, use RestoreStateM() to restore the driver's
- state.
-
- See Also: GetSizeM, RestoreStateM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
- Page 29
-
-
-
- RestoreStateM
- =====================================================================
-
- Restore mouse environment.
-
- Use in conjunction with: GetSizeM, SaveStateM
-
- DECLARE SUB RestoreStateM(Buffer$, ErrNum%)
-
- Syntax: CALL RestoreStateM(Buffer$, ErrNum%)
-
- Buffer$ Contains a previously saved mouse state.
-
- ErrNum% Returns a -1, if Buffer$ is smaller than the mouse
- environment.
-
- Example:
-
- ' Amount of memory needed to hold the mouse state.
- Size% = GetSizeM%
-
- Buffer$ = SPACE$(Size%) ' Pad buffer with spaces.
-
- CALL SaveStateM(Buffer$, ErrNum%) ' Save mouse state.
-
- CALL HidePointer
-
- SHELL"XXXX" ' Pass control.
-
- CALL ShowPointer
-
- CALL RestoreStateM(Buffer$, ErrNum%) ' Restore state.
-
- Comments:
-
- You must have used the SaveStateM() routine to save the mouse
- state in Buffer$ before calling this routine.
-
- See Also: GetSizeM, SaveStateM
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
-
-
-
-
-
-
-
- Page 30
-
-
-
- Sample Pointer Shapes
- =====================================================================
-
- Change the shape of the mouse pointer (graphics only).
-
- DECLARE SUB <shape name>
-
- Syntax: CALL <shape name>
-
- ARROW0
- HANDV0
- HOURGLASS0
- PEN0
- MAGNIFYGLASS0
- PAINTCUP0
- MOUSE0
- WHATCH0
- ARROW1
-
- Example:
-
- CALL HANDV0 'Change pointer to a hand shape.
-
-
- Comments:
-
- A zero appended to a shape name denotes a color pointer, A
- one(1) denotes inverted or non-colored pointer.
-
- ---------------------------------------------------------------------
- Assembly routines
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 31
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- =====================================================================
-
-
-
-
- Mouse Toolkit Routines
-
-
-
-
- =====================================================================
-
-
-
- InMouseState
- =====================================================================
-
- Returns the status of the event handler.
-
- DECLARE FUNCTION InMouseState% ()
-
- Syntax: Value% = InMouseState%
-
- Value% A bit-field argument with bits reflecting the status
- of the event handler.
-
- Status Values: 0 - Handler is not installed
- 2 - Handler is enabled
- 4 - Handler is disabled
- Example:
-
- Value% = InMouseState%
-
- IF Value% = 0 THEN PRINT "Handler is not installed"
- IF Value% AND 2 THEN PRINT "Handler is enabled"
- IF Value% AND 4 THEN PRINT "Handler is disabled"
-
- Comments: For a working example see: MLIBSAM6.BAS
-
- ---------------------------------------------------------------------
- BASIC function
-
-
- GetEventsPending
- =====================================================================
-
- Returns the number of mouse events currently pending in the buffer.
-
- DECLARE FUNCTION GetEventsPending% ()
-
- Syntax: Value% = GetEventsPending%
-
- Value% The number of mouse events currently waiting in the
- event buffer.
-
- Example: For a working example see: MLIBSAM6.BAS
-
- Comments: Use InMouseHandler() to clear events from the buffer.
-
- See Also: InMouseHandler, Clearing the Event Buffer
-
- ---------------------------------------------------------------------
- BASIC function
-
-
-
-
-
- Page 32
-
-
-
- GetEventMask
- =====================================================================
-
- Returns current event mask.
-
- Use in conjunction with: SetEventMask
-
- DECLARE SUB GetEventMask(Mask%)
-
- Syntax: CALL GetEventMask(Mask%)
-
- Mask% A bit-field argument with bits corresponding to
- mouse events that are currently being captured.
-
-
- Example:
-
- ' Get and save the current event mask.
- CALL GetEventMask(OldMask%)
-
- ' Set mouse movement bit.
- NewMask% = OldMask% OR 1
-
- ' Tell the event handler to begin capturing mouse movement.
- CALL SetEventMask(NewMask%)
-
- ' Do something that requires mouse movement.
- ' .
- ' .
- ' .
-
- ' Restore the original event mask.
- CALL GetEventMask(OldMask%)
-
- Comments:
-
- Use this procedure and SetEventMask() when you need to alter
- the events currently being captured. See the Event bit-field
- table, under the InMouse heading. This table shows all the
- different mouse events that can be captured.
-
- For a working example see: MLIBSAM6.BAS
-
- See Also: SetEventMask
-
- ---------------------------------------------------------------------
- BASIC subroutine
-
-
-
-
-
-
-
- Page 33
-
-
-
- SetEventMask
- =====================================================================
-
- Informs the mouse event handler to begin capturing specified events.
-
- Use in conjunction with: GetEventMask
-
- DECLARE SUB SetEventMask(Mask%)
-
- Syntax: CALL SetEventMask(Mask%)
-
- Mask% A bit-field argument that specifies which mouse
- events are to be captured.
-
- Example:
-
- ' Get and save the current event mask.
- CALL GetEventMask(OldMask%)
-
- ' Set mouse movement bit.
- NewMask% = OldMask% OR 1
-
- ' Tell the event handler to begin capturing mouse movement.
- CALL SetEventMask(NewMask%)
-
- ' Do something that requires mouse movement.
- ' .
- ' .
- ' .
-
- ' Restore the original event mask.
- CALL GetEventMask(OldMask%)
-
- Comments:
-
- Use this procedure and GetEventMask() when you need to alter
- the events currently being captured. See the Event bit-field
- table, under the InMouse heading. This table shows all the
- different mouse events that can be captured.
-
- For a working example see: MLIBSAM6.BAS
-
- See Also: GetEventMask
-
- ---------------------------------------------------------------------
- BASIC subroutine
-
-
-
-
-
-
-
-
- Page 34
-
-
-
- GetDblClkSettings
- =====================================================================
-
- Returns current double-click settings.
-
- DECLARE SUB GetDblClkSettings(ClickS%, ClickW%, ClickH%)
-
- Syntax: CALL GetDblClkSettings(ClickS%, ClickW%, ClickH%)
-
- ClickS% Time frame in which the event handler will register
- a double-click.
-
- ClickW% Specifies the width (in pixels, on either side)
- that the pointer can move between clicks when
- double-clicking.
-
- ClickH% Specifies the height (in pixels, above and below)
- that the pointer can move between clicks when
- double-clicking.
-
- Example:
-
- ' Save current settings.
- CALL GetDblClkSettings(OldClickS%, OldClickW%, OldClickH%)
-
- ClickS% = 9 ' Allow 1/2 second in which a double-click will
- be registered.
-
- ClickW% = 4 ' Allow 8 pixels in total of horizontal pointer
- pointer movement.
-
- ClickH% = 4 ' Allow 8 pixels in total of vertical pointer
- pointer movement.
-
- ' Use the new settings.
- CALL SetDblClkSettings(ClickS%, ClickW%, ClickH%)
-
- Comments:
-
- There are 18 (approx.) clock ticks per second.
-
- Default double-click settings: 6 - Double-click speed
- 2 - Double-click width
- 2 - Double-click height
-
- For a working example see: MLIBSAM6.BAS
-
- See Also: SetDblClkSettings
-
- ---------------------------------------------------------------------
- BASIC subroutine
-
-
-
- Page 35
-
-
-
- SetDblClkSettings
- =====================================================================
-
- Change current double-click settings.
-
- DECLARE SUB SetDblClkSettings(ClickS%, ClickW%, ClickH%)
-
- Syntax: CALL SetDblClkSettings(ClickS%, ClickW%, ClickH%)
-
- ClickS% Time frame in which the event handler will register
- a double-click.
-
- ClickW% Specifies the width (in pixels, on either side)
- that the pointer can move between clicks when
- double-clicking.
-
- ClickH% Specifies the height (in pixels, above and below)
- that the pointer can move between clicks when
- double-clicking.
-
- Example:
-
- ' Save current settings.
- CALL GetDblClkSettings(OldClickS%, OldClickW%, OldClickH%)
-
- ClickS% = 9 ' Allow 1/2 second in which a double-click will
- be registered.
-
- ClickW% = 4 ' Allow 8 pixels in total of horizontal pointer
- pointer movement.
-
- ClickH% = 4 ' Allow 8 pixels in total of vertical pointer
- pointer movement.
-
- ' Use the new settings.
- CALL SetDblClkSettings(ClickS%, ClickW%, ClickH%)
-
- Comments:
-
- There are 18 (approx.) clock ticks per second.
-
- Default double-click settings: 6 - Double-click speed
- 2 - Double-click width
- 2 - Double-click height
-
- For a working example see: MLIBSAM6.BAS
-
- See Also: GetDblClkSettings
-
- ---------------------------------------------------------------------
- BASIC subroutine
-
-
-
- Page 36
-
-
-
- InMouseSave
- =====================================================================
-
- Save the event handler's state.
-
- Use in conjunction with: InMouseRestore
-
- DECLARE SUB InMouseSave(Buffer$)
-
- Syntax: CALL InMouseSave(Buffer$)
-
- Buffer$ Returns a 132 byte string containing the event
- handler's internal data storage block.
-
- Example: For a working example see: MLIBSAM6.BAS
-
- Comments: Use this procedure to save the current instance of the
- event handler before performing some task that may alter
- some or all internal settings.
-
- See Also: InMouseRestore, SaveStateM, RestoreStateM
-
- ---------------------------------------------------------------------
- BASIC subroutine
-
-
- InMouseRestore
- =====================================================================
-
- Restore a previously saved instance of the event handler.
-
- Use in conjunction with: InMouseRestore
-
- DECLARE SUB InMouseSave(Buffer$)
-
- Syntax: CALL InMouseRestore(Buffer$)
-
- Buffer$ Contains the event handler's internal data storage
- block.
-
- Example: For a working example see: MLIBSAM6.BAS
-
- Comments: IMPORTANT: InMouseSave() and InMouseRestore() save and
- restore the event handler's state, NOT the mouse driver's
- state.
-
- See Also: InMouseSave, SaveStateM, RestoreStateM
-
- ---------------------------------------------------------------------
- BASIC subroutine
-
-
-
-
- Page 37
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- =====================================================================
-
-
-
-
- Additional Routines
-
-
-
-
- =====================================================================
-
-
-
- CviBin
- =====================================================================
-
- Returns a binary string representation of a decimal value.
-
- DECLARE FUNCTION CviBin$ (BYVAL Value%)
-
- Syntax: Binary$ = CviBin$ (Value%)
-
- Binary$ Returns a 16 byte string that represents the binary
- value of the passed argument.
-
- Value% Value to convert.
-
-
- Example: For a working example see: MLIBSAM6.BAS
-
- Comments: The returned string is always 16 bytes in length, even if
- the passed argument's value was zero.
-
- ---------------------------------------------------------------------
- Assembly function
-
-
-
- CvsBin
- =====================================================================
-
- Converts a binary string representation into a decimal value.
-
- DECLARE FUNCTION CvsBin% (Binary$)
-
- Syntax: Value% = CvsBin% (Binary$)
-
- Value% Returned decimal value.
-
- Binary$ A 16 byte string that represents a 16 bit binary
- value.
-
- Example: For a working example see: MLIBSAM6.BAS
-
- Comments: The string passed to this routine must be 16 bytes in
- length.
-
- ---------------------------------------------------------------------
- Assembly function
-
-
-
-
-
-
-
-
- Page 38
-
-
-
- GetWord
- =====================================================================
-
- Returns two bytes from specified memory location.
-
- DECLARE FUNCTION GetWord% (BYVAL Segment%, BYVAL Offset%)
-
- Syntax: Value% = GetWord(Segment%, Offset%)
-
- Value% Returned value from specified memory location.
-
- Segment% Source segment part of address.
-
- Offset% Source offset part of address.
-
- Example: For a working example see: MLIBTOOL.BAS
-
- Comments: Use this routine when you need to read two bytes at one
- time, it will be faster than using BASIC's PEEK function
- twice.
-
- ---------------------------------------------------------------------
- Assembly function
-
-
-
- PutWord
- =====================================================================
-
- Writes two bytes to specified memory location.
-
- DECLARE SUB PutWord(BYVAL Segment%, BYVAL Offset%, BYVAL Value%)
-
- Syntax: CALL PutWord(Segment%, Offset%, Value%)
-
- Segment% Destination segment part of address.
-
- Offset% Destination offset part of address.
-
- Value% Value to write to specified memory location.
-
- Example: For a working example see: MLIBTOOL.BAS
-
- Comments: Use this routine when you need to write two bytes at one
- time, it will be faster than using BASIC's POKE statement
- twice.
-
- ---------------------------------------------------------------------
- Assembly subroutine
-
-
-
-
-
- Page 39
-
-
-
- InWinM
- =====================================================================
-
- Check if pointer is in a specified area on the screen.
-
- DECLARE FUNCTION InWinM% (BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%)
-
- Syntax: Value% = InWinM(x1%, y1%, x2%, y2%)
-
- Value% Returns a -1 if true, else 0.
-
- x1%, x2% Left and right boundaries (in pixels).
-
- y1%, y2% Top and bottom boundaries (in pixels).
-
- Example:
-
- ' $INCLUDE: 'MLIB.BI'
-
- SCREEN 12
-
- CALL InitPointer(X%)
- CALL SetPointer(0, 0)
-
- x1% = 0
- y1% = 0
- x2% = 100
- y2% = 100
-
- LINE (x1%, y1%)-(x2%, y2%), , B
-
- CALL ShowPointer
-
- ' Loop while pointer is in the given coordinates.
- DO
-
- InIt% = InWinM(x1%, y1%, x2%, y2%)
-
- LOOP WHILE InIt%
-
- SCREEN 0
-
- Comments:
-
- BYVAL is used here for speed.
-
- NOTE: This function will not work properly using a screen
- resolution of 320 X 200.
-
- ---------------------------------------------------------------------
- Assembly function
-
-
-
- Page 40
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- =====================================================================
-
-
-
-
- Miscellaneous Information
-
-
-
-
- =====================================================================
-
-
-
- Miscellaneous Information
- =====================================================================
-
- Discontinued Routines:
-
- The following routines have been discontinued and are no
- longer supported:
-
- DClicBut()
- DClicM()
- DClicOff()
- DClicOn()
- DClicRate()
-
- The mouse event handler now handles all the double-click
- events.
-
- See: InMouseHandler
-
-
- MLIB and Visual Basic Forms:
-
- MLIB was designed to provide mouse support in a Visual Basic
- form-free environment. Calling any of MLIB's mouse routines
- while forms are showing may conflict with Visual Basic's
- built-in mouse handling procedures and produce unpredictable
- results. It is possible to combine the two handlers if these
- guidelines are followed:
-
- 1. Hide ALL Visual Basic forms before accessing ANY of MLIB's
- mouse routines.
-
- 2. Once the forms are hidden, initialize MLIB (by calling
- InitPointer()), or restore a previously saved instance
- of the mouse driver.
-
- 3. When you are ready to give mouse control back to Visual
- Basic (you could save this instance of the mouse for form-
- free use), just re-show the forms.
-
-
- For Example:
-
- ' Hide the Visual Basic form.
- VBForm.HIDE
-
- ---------------------------------------------------------------------
- Continued...
-
-
-
-
-
-
- Page: 41
-
-
-
- Miscellaneous Information
- =====================================================================
-
- MLIB and Visual Basic Forms: (continued...)
-
- ' If we have previously saved our own mouse state then
- ' restore and use this instance, it will be faster than
- ' re-initializing.
- IF IsSaved% THEN
- CALL RestoreStateM(MyMouseState$, RestoreErr%)
- ELSE
- CALL InitPointer(X%)
- END IF
-
- CALL ShowPointer
-
- ' MLIB is now ready to be used.
- '.
- '.
- '.
-
- ' Reverse cycle; hide the pointer and save this instance
- ' of the mouse for later use, then give control back to
- ' Visual Basic.
-
- CALL HidePointer
-
- ' Create a buffer and save the mouse state.
- MyMouseState$ = SPACE$(GetSizeM%)
- CALL SaveStateM(MyMouseState$, SaveErr%)
-
- ' Show that we saved the mouse state.
- IF NOT SaveErr% THEN
- IsSaved% = -1
- END IF
-
- ' Show the VB form.
- VBForm.SHOW
-
- See: GetSizeM, SaveStateM, RestoreStateM
-
-
- MLIB Versus the Basic Editor:
-
- Basic refers to QuickBASIC or Visual Basic.
-
- When developing a program in the Basic editing environment,
- the editor and MLIB must of course share the same mouse
-
- ---------------------------------------------------------------------
- Continued...
-
-
-
- Page: 42
-
-
-
- Miscellaneous Information
- =====================================================================
-
- MLIB Verses the Basic Editor: (continued...)
-
- driver which under certain conditions can lead to temporary
- mouse failure. This "problem" is more likely to occur when
- debugging; when your executing code stops due to breakpoints
- (or errors) etc., leaving MLIB's mouse handler still active.
- When this happens the editor's mouse may not respond and
- under certain circumstances the pointer may disappear
- altogether. For the editor to regain control of the mouse,
- MLIB must release its control of the mouse driver. This can
- be done by typing "END" in the Immediate window and pressing
- Enter or if possible, continue executing your program to
- normal termination. MLIB will always remove its link with the
- mouse driver when your program ends (even if a critical
- error terminates your program). Once compiled, and outside
- the Basic environment, our handler is on it's own, and this
- will no longer pose a problem.
-
- NOTE: This condition only occurs when using MLIB's internal
- event-driven mouse handler (InMouseHandler()).
-
-
- How To Contact the Author:
-
- If you wish to contact me for any reason at all, here is my
- phone number and mailing address:
-
- Phone: 1-306-379-4505
-
- TERRY VENN
- BOX 3A-10,
- D'ARCY, SK.,
- S0L 0N0, CANADA.
-
- If you reach my answering machine, leave your name and number
- and I will return your call as soon as possible.
-
- Just so there are no surprises; I run this business out of my
- own home. Don't be shocked if one of my inquisitive sons beat
- me to the phone and chatter inanely.
-
- ---------------------------------------------------------------------
- Continued...
-
-
-
-
-
-
-
-
- Page: 43
-
-
-
- Miscellaneous Information
- =====================================================================
-
- Registration Fee:
-
- The registration fee is $25.00 US/CDN, plus $2.50 for
- shipping and handling (US, or CDN funds only). Payment must
- be made in the form of a money order or check. Checks must be
- drawn on a US or CDN bank. There may be a delay in processing
- orders for non-certified check clearance. All orders are
- shipped by air mail. Foreign orders are welcome.
-
- NOTE: The fee for upgrading from a previous version of MLIB
- is $12.50 plus $2.50 for shipping and handling.
-
- How To Register:
-
- To register with the author and receive a copy of the latest
- release of this software, fill out the order form (ORDER.FRM)
- and send it along with the registration fee to the address
- below:
-
- TERRY VENN
- BOX 3A-10,
- D'ARCY, SK.,
- S0L 0N0, CANADA.
-
- To send a copy of the order form to your printer:
-
- 1. Place the MLIB diskette into drive A.
- 2. Log onto drive A by typing: A: <Press Enter>
- 3. To begin printing type: COPY ORDER.FRM PRN <Press Enter>
-
- IMPORTANT: Please print clearly when filling out the order
- form. Prefered method is to fill out the ORDER.FRM file using
- a text editor.
-
- Registered Users Will Receive:
-
- 1. The latest release of MLIB.
- 2. A license or the right to distribute .EXE's that contain
- MLIB routines.
- 3. Free phone/mail support.
- 4. ME.EXE, a mouse pointer shape editing tool.
- 5. CVTASM.EXE, a command line utility that converts raw
- pointer shape data into assembly code, which can be
- assembled and added to your library.
- 6. ASC2SHP.BAS, a shape editing tool written in BASIC.
- 7. SHP2ASC.BAS, coverts raw pointer shape data into ASCII
- text which can then be edited by ASC2SHP.BAS.
-
- ---------------------------------------------------------------------
-
-
- Page: 44
-