Contents of the RODENT.DOC file
Adapted from an article in "The Linker" the monthly
newsletter of the Professional Association of Database
Clipper developers can use UDF's created in Assembler to
directly interrogate the mouse driver. There are numerous
advantages and disadvantages to this approach - the key
disadvantage is that the developer must constantly call the
mouse driver to determine the status of the mouse. This
means that the developer cannot rely on any "wait state"
input (accept, input, read, wait, ...) if they wish to use
the mouse as an alternative to the keyboard at the same
time. The structure of the most simple code changes from:
*** Sample routine to get input without mouse
accept to string
*** Sample routine to get input with the mouse
*** demonstration purposes only
*** mrow() returns current mouse row as integer
*** mcol() returns current mouse column as integer
*** mbutleft() returns .T. if left button is pressed
* initialize string
string = ""
do while .T.
x = 0 && clear value for key press
* test mouse
case mrow() = 10 .and. mcol() = 20 .and. mbutleft()
string = "First Line"
case mrow() = 12 .and. mcol() = 20 .and. mbutleft()
string = "Second Line"
x = inkey()
if x = 13
* enter pressed
if x > 0
* key pressed, build string
string = string+chr(x)
As you can see, the code modifications required to
incorporate the mouse into your applications is no trivial
undertaking. The inability to use the mouse in "wait-state"
input may make it's use, in other than the keyboard
emulation mode, impractical for many applications (if all
you require is keyboard emulation, see some of the other
packages available on the market).
Now that you've seen what is involved in adding mouse
support to your programs, lets examine the functions
required for basic mouse support. The object file RODENT.OBJ
contains 11 functions to support low level calls to any
Microsoft compatible mouse driver (including IBM, Logitech
and most others). It will support applications in the 25
row, 80 column text mode only.
ISMOUSE() - Returns .T. if mouse driver is present
MRESET() - Resets the mouse driver, returns # of buttons on
MSHOW() - Display mouse cursor
MHIDE() - Hides the mouse cursor
MROW() - Returns current mouse cursor row (int)
MCOL() - Returns current mouse cursor column (int)
MLEFT() - Returns .T. if left mouse button is pressed
MRIGHT() - Returns .T. if right mouse button is pressed
MCENTER() - Returns .T. if center mouse button is pressed
,) - Moves mouse cursor to position
specified by row, col
MAREA(,,,) - Limits mouse
cursor movement to area specified by uprow, upcol,
None of the functions do any error checking, the developer
must insure the values passed to MTOPOS and MAREA are valid.
If there is no center button the mouse, the result of
calling mcenter will depend upon the driver loaded
(Microsoft's drivers will return .F.).
Using the above functions, we can monitor the mouse's
movement and button status, enabling the creation of pop-up
boxes such as:
*** Displays message on screen,
*** wait for button release in message box
* clear message area in reverse
set color to N/W
@ 10,20 clear to 15,59
@ 10,20 to 15,59 double
@ 11,25 say popmsg
@ 12,25 to 14,54 single
@ 12,28 say "Click Mouse Here to Go On"
* set button flag
butdown = .F.
do while .T.
* button pressed, set flag
butdown = .T.
if ! mleft() .and. butdown
* button released, check position
if mrow() >= 12 .and. mrow() <= 14 .and.;
mcol() >= 25 .and. mcol() <= 54
* mouse cursor in box
* button release outside of box,
* reset button flag to start again
butdown = .F.
if inkey() = 13
* return key pressed
The structure outlined above is basic to most programs that
make use of the mouse, more complicated programs can offer a
variety of actions depending upon the position of the mouse
cursor and the button press/release sequence.
Once you have created functions that are mouse "aware", you
can easily add support for other alternative input devices
(including my personal favorite - the light pen, support for
which can be found in "LIGHTPEN", available from the same
friendly disks from where you plucked this) to your code.
A full demo of the mouse functions is included in this
archive, entitled "MDEMO.PRG". Compile MDEMO and link it
with RODENT (i.e. "link mdemo rodent,,,clipper") to try the
mouse for yourself!
Lawrence Edward Nussbaum
Contact via: Compuserve 76137,361
The Source BDW207
Microsoft Mouse Programmers Reference Guide, 1986/1987,
Microsoft Corporation, Redmond, Washington