📄 moustrap.prn
字号:
P
The MouseTrap Library
High & Low Level Mouse Control
Functions for 'C' Programs
Version 1.0
By James M. Curran.
24 Greendale Road
Cedar Grove, NJ
07009-1313
G Table of ContentsH
1. Introduction.................. 3
Registration.................. 3
Warranty...................... 3
2. GBasic Mouse Control FunctionsH 4
Check_Mouse()................. 5
Show_Mouse().................. 6
Hide_Mouse().................. 6
Get_Mouse_Position().......... 7
Set_Mouse_Position().......... 8
Get_Mouse_Press()............. 9
Get_Mouse_Release()........... 9
Set_Mouse_Limit()............. 10
Set_Mouse_Text_Cursor()....... 11
3. GAdvanced Mouse Control FunctionsH 12
Activate_Mouse_Page().......... 13
Add_Mouse_Page()............... 14
Add_Mouse_Button()............. 15
Add_Mouse_Hot_Spot()........... 16
Clear_All_Mouse_Definitions().. 17
Clear_Mouse_Pages()............ 18
DeActivate_Mouse_Page()........ 19
Define_Mouse_System().......... 20
Delete_Mouse_Page()............ 21
Delete_Mouse_Button().......... 21
Delete_Mouse_Hot_Spot()........ 21
Get_Char_Mouse_Kbd()........... 22
Read_Mouse()................... 23
4. GUsing the MouseTrap LibraryH 24
5. GTechnical SpecificationsH 29
(only in registered versions)
6. GAppendixH 30
A. MOUSTRAP.H............... 31
B. Global Variables......... 32
C. Errors................... 33
D. Reference................ 34
E. Support.................. 35
2
GIntroductionH
The MouseTrap library is a collection of functions to
control a mouse, designed to be called from a 'C' program. They
provide easy access to the low-level functions of the mouse
interrupt, as well as a simplified system for high-level control
over the mouse. The basic functions are mostly self explanatory
and are described in chapter 2 of the document. The high-level
functions are a bit more complicated. They are described in
Chapter 3 with a tutorial in Chapter 4.
GRegistrationH
The MouseTrap Library is copyrighted by James M. Curran.
You are granted a limited license to use MouseTrap, for
noncommercial programs. You may, and are in fact encouraged, to
copy and distribute it, provided that the following conditions
are met: (a) No fee may be charged for copying or distributing,
and (b) only the library files (*.LIB) and accompanying
documentation are distributed, and only in their original,
unmodified form.
Sending a voluntary contribution of $15.00 will appease your
guilt, and earn you my undying gratitude. It will also get you a
copy of the source code, the Compact (CMOUSE.LIB) & Medium
(MMOUSE.LIB) memory model libraries, the missing chapter from
this booklet, and other assorted related files. Microsoft C 5.1
& MASM 5.1 are needed to recompile the source files, (unless
modified by the user).
Contributions, (and requests for information on commercial
licenses) should be sent to :
James M. Curran
24 Greendale Road
Cedar Grove, NJ 07009-1313
Finally, there's only one thing you can say for sure about a
"Version 1.0" release of software--- That it will soon be
followed by a "Version 1.01" Bug-Fix release. So, all registered
user will be sent that version when it's ready. (That's merely
cautionary; there are no known bugs at this time).
GWarrantyH
Warranty ? We make no promises that the MouseTrap library
will do anything useful for you. Nor do we promise that it WON'T
do anything harmful. (Life's Tough; "Want do you want for
nothing ? Rubber Biscuit ?")
3
MouseTrap Library
September 21, 1988
Chapter 2:
GBasic Mouse Control FunctionsH
The eleven primitives that make up the low-level support
functions are almost direct calls to the mouse driver interrupt,
and are written in 8086 assembler. They were originally derived
from a set of 'C' functions given in an article in "The 'C'
Gazette" (see references at end), but since then numerous
revision have transformed them. The only thing left are the
names of two functions.
Check_Mouse() Get_Mouse_Press()
Show_Mouse() Get_Mouse_Release()
Hide_Mouse() Set_Mouse_Text_Cursor()
Get_Mouse_Position()
Set_Mouse_Position()
Set_Mouse_Limits()
- Page 4 -
MouseTrap Library
September 21, 1988
Check_Mouse - Check for the existence and type of a Mouse.
GSyntax:H
#include <moustrap.h>
mouse_t Check_Mouse(void);
GDescription:H
This function initialized the mouse interrupt driver, and
must be the first low-level function called (but see
Define_Mouse_System()). It check to see if a mouse is attached
(or to be exact, if a mouse device driver is loaded into memory),
and if one is present, determines how many buttons it has. This
information is return by the function, and is also stored in the
global variable "_mouse_there".
GReturns Value:H
If no mouse is detected, the Check_Mouse function returns 0.
If a mouse IS detected, the number of buttons on it is returned.
These values are also stored in the global _mouse_there. This can
also be used as a TRUE/FALSE indicator.
GSee Also:H
Define_Mouse_System, _mouse_there
GExample:H
#include <moustrap.h>
#include <stdio.h>
main()
{
Check_Mouse();
if (_mouse_there)
printf("A %d-button Mouse was detected.\n",_mouse_there);
else
printf("No mouse was found.\n");
}
- Page 5 -
MouseTrap Library
September 21, 1988
Show_Mouse - Display Mouse Cursor.
Hide_Mouse - Hide Mouse Cursor.
GSyntax:H
#include <moustrap.h>
void Show_Mouse(void);
void Hide_Mouse(void);
GDescription:H
GH Show_Mouse causes the mouse cursor to be displayed on the
screen. Hide_Mouse cause the mouse cursor to disappear. Neither
will have any effect if there is no mouse or Check_Mouse has not
been executed yet.
GH
GReturns Value:H
There is no return value.
GSee Also:H
Check_Mouse, _mouse_there
GExample:H
#include <moustrap.h>
#include <stdio.h>
main()
{
Check_Mouse();
}
- Page 6 -
MouseTrap Library
September 21, 1988
Get_Mouse_Position
GSyntax:H
#include <moustrap.h>
mouse_t Get_Mouse_Position(mouse_t *X, mouse_t *Y);
GDescription:H
Get_Mouse_Position places the X (Horizontal) and Y
(Vertical) coordinates of the present location of the mouse cursor
into the locations given by X & Y. The locations are given using
graphic coordinates in the range (0,0) to (639,199).It also return
the binary sum of the buttons pressed. If _mouse_there indicates
that no mouse was detected, the values of X & Y are left unchanged,
and the function returns 0.
GReturn Value:H
The binary sum of the buttons pressed, where the Left button
equals 1, the Right button equals 2, and the Middle button, 4.
These value are added together if more than one button is pressed.
For example, pressing the Left & Middle buttons would have
Get_Mouse_Position return a value of 5.
GSee Also:H
_mouse_there, Set_Mouse_Position
GExample:H
#include <moustrap.h>
#include <stdio.h>
main()
{
int X,Y,m;
Check_Mouse();
do {
m = Get_Mouse_Position( &X, &Y);
if (m & 1)
printf("Left Button, ");
if (m & 2)
printf("Right Button, ");
if (m & 4)
printf("Middle Button, ");
if (m)
printf("pressed at (%d, %d)\n",X,Y);
} while (m==0);
}
Pressing the Left & Right buttons would print something
similar to:
GLeft Button, Right Button pressed at (120, 85)H
- Page 7 -
MouseTrap Library
September 21, 1988
GH Set_Mouse_Position
GSyntax:H
#include <moustrap.h>
void Set_Mouse_Position(mouse_t X, mouse_t Y);
GDescription:H
The function Set_Mouse_Position moves the mouse cursor to
the screen location given by the graphic coordinates (X,Y). X must
be in the range (0-639) and Y in the range (0-199).
GReturn Value:H
None.
GSee Also:H
GH Get_Mouse_Position
GExample:H
#include <moustrap.h>
#include <stdio.h>
main()
{
int X,Y,m;
Check_Mouse();
Show_Mouse();
Get_Mouse_Position( &X, &Y);
X++;
Y--;
Set_Mouse_Position( X, Y);
}
The above program would move the mouse cursor, "Up" and to
the "Right", without the mouse physically being moved.
- Page 8 -
MouseTrap Library
September 21, 1988
Get_Mouse_Press
Get_Mouse_Release
GSyntax:H
mouse_t Get_Mouse_Press(mouse_t Button, mouse_t Status,
mouse_t *X, mouse_t *Y);
mouse_t Get_Mouse_Release(mouse_t Button, mouse_t Status,
mouse_t *X, mouse_t *Y);
GDescription:H
Get_Mouse_Press returns information about the last press of
one of the mouse buttons, given by the code "Button". The
coordinates of the location of the mouse cursor the last time that
button was pressed are returned in X & Y. The Function itself
returns the number of times that button was pressed since the last
time Get_Mouse_Press was called. The binary sum of the buttons
currently pressed, as described in Get_Mouse_Position, is returned
in Status.
Get_Mouse_Release works exactly the same way, with X and Y
giving the location of the last position the button was released.
GReturn Value:H
GH
The number of time Button was pressed (released) since the
last call to Get_Mouse_Press (Get_Mouse_Release).
GSee Also:H
Get_Mouse_Position
GExample:H
#include <moustrap.h>
#include <stdio.h>
main()
{
mouse_t s,x,y;
if (Check_Mouse()) {
getch() /* pause of while */
if (Get_Mouse_Press(M_Left,&s,&x,&y))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -