moustrap.prn
来自「又一个关于鼠标驱动的C程序」· PRN 代码 · 共 2,261 行 · 第 1/5 页
PRN
2,261 行
Return Value:
MNOERROR if there was no problem; otherwise
MERROR with the specific error given in M_Error
See Also:
M_Error Activate_Mouse_Page, Clear_Mouse_Pages
Example:
See Chapter 4.
- Page 23 -
MouseTrap Library, Rel 1.01
February 12, 1989
Define_Mouse_System
Syntax:
#include <moustrap.h>
mouse_t Define_Mouse_System(Page_Type);
mouse_t Page_type;
Description:
Define_Mouse_System declares how mouse pages are to be used
through the program. Page_Type must be either M_Overlaid_Pages
or M_Single_Pages. Automatically initializes mouse by
executing Check_Mouse. Can only be done once in a program
unless reset with Clear_All_Mouse_Definitions.
Return Value:
MNOERROR if there was no problem; otherwise
MERROR with the specific error given in M_Error
See Also:
M_Error, Clear_All_Mouse_Definitions, Check_Mouse
Example:
See Chapter 4.
- Page 24 -
MouseTrap Library, Rel 1.01
February 12, 1989
Delete_Mouse_Button
Delete_Mouse_Hot_Spot
Delete_Mouse_Page
Syntax:
#include <moustrap.h>
mouse_t Delete_Mouse_Button(mouse_t Page_ID, mouse_t Button);
mouse_t Delete_Mouse_Hot_Spot(mouse_t HS_ID);
mouse_t Delete_Mouse_Page(mouse_t Page_ID);
Description:
Removes the indicated item from the system.
Return Value:
MNOERROR if there was no problem; otherwise
MERROR with the specific error given in M_Error
See Also:
M_Error
Example:
See Chapter 4.
- Page 25 -
MouseTrap Library, Rel 1.01
February 12, 1989
Get_Char_Mouse_Kbd
Syntax:
#include <moustrap.h>
mouse_t Get_Char_Mouse_Kbd(void);
Description
Get_Char_Mouse_Kbd acts much like the standard library
function GETCH, but will accept input from either the
keyboard or the mouse. Will return only when some input is
received from the keyboard or mouse.
Return Value:
The value inputted if there was no problem; otherwise
MERROR with the specific error given in M_Error
See Also:
M_Error, Read_Mouse
Example:
See Chapter 4.
- Page 26 -
MouseTrap Library, Rel 1.01
February 12, 1989
Read_Mouse
Syntax:
#include <moustrap.h>
mouse_t Read_Mouse(void)
Description:
Checks mouse for input.
Return Value:
The Return_value assigned to a Button or Hot Spot, if that
item was "clicked" on, or
MERROR if an error occured, or
0 if no button was pressed.
See Also:
M_Error, Get_Char_Mouse_Kbd
Example:
See Chapter 4.
NOTE:
Remember, a non-zero return value does not necessarily mean
a button was pressed; it could also indicate an error
condition. (MNOINIT or MNOACTIVE).
- Page 27 -
MouseTrap Library, Rel 1.01
February 12, 1989
Read_Mouse_Kbd
Syntax:
#include <moustrap.h>
mouse_t Read_Mouse_Kbd(void)
Description:
Something between Read_Mouse and Get_Mouse_Kbd_Char.
Checks mouse and the keyboard for input.
Return Value:
The Return_value assigned to a Button or Hot Spot, if that
item was "clicked" on, or
a key pressed on the keyboard.
MERROR if an error occured, or
0 if no button or key was pressed.
See Also:
M_Error, Get_Char_Mouse_Kbd
Example:
See Chapter 4.
NOTE:
Remember, a non-zero return value does not necessarily mean
a button was pressed; it could also indicate an error
condition. (MNOINIT or MNOACTIVE).
- Page 28 -
MouseTrap Library, Rel 1.01
February 12, 1989
Chapter 4
Using the MouseTrap Library
The basic concept of the MouseTrap is the "Mouse Page". A
Mouse Page is one set of button and "Hot spot" definitions. Any
character can be assigned to a button or hot spot. Pages can be
used in either of two ways: You can have up ot 65,000 single pages,
which can only be used one at a time, or up to 16 page "overlaid"
pages, any combination of which can be active at once. You choose
this by using the Define_Mouse_System function, with either
M_Single_Pages or M_Overlaid_Pages.
The next step is to define a page, by using the Add_Mouse_Page
function, passing to it the "type" of page it is, either M_Graphic_Coord
or M_Text_Coord; and the 4 corner points for that page using the
appropriate set of coordinates (either 80x25 or 640x200). Using "0"
for each corner will have it using the entire screen. Add_Mouse_Page
will return an ID number for the page, which you will be using in all future
references to this page.
Next, you must define the buttons you will be using. This is done
with Add_Mouse_Button. You tell it which for which page and button
this definition is to apply, and the value to return if that button was
clicked while that page was active. If you use "0" for the Page ID,
this definition will apply to all pages. If you use "0" for the
return value, you can have that button return different values for
being clicked at different "hot spots" within the page.
If you are using hot spots in a page, you must next call Add_Mouse-
_Hot_Spot, passing to it the page ID and button code, the corner
points, and the return value for the spot.
Now, we get to the fun part. Choose a page using the Activate-
_Mouse_Page function. Using overlaid page, you can have several
pages active at once; remove them with the DeActivate_Mouse_Page or
Clear_Mouse_Pages function. In single page mode, activating a new page
automatically deactivates the last one.
Finally, simply call Read_Mouse(). It will return either the
value for the button or Hot spot clicked or 0 if no button was
clicked. Or simpler still, use Get_Char_Mouse_Kbd(), which waits
until some input is entered by either keyboard or mouse.
- Page 29 -
MouseTrap Library, Rel 1.01
February 12, 1989
To further exemplify the process let's examine the sample
program MICETEST.C:
#include <stdio.h>
#include "moustrap.h"
#include <graph.h>
main ()
{
mouse_t y,z,c;
The data type "mouse_t" is defined in MOUSTRAP.H. All variables
used with the MouseTrap library should be define as this type.
The first group of lines setup the screen so it's easier to
understand what's happening with the mouse. But by themselves they
do nothing of interest to this discussion. Ignore them and skip down a
bit.
Define_Mouse_System(M_Single_Pages);
For the first step, we going to be using single pages; only one
of the pages we're about the define can be active at only given time.
y=Add_Mouse_Page(M_Text_Coord,15,20,24,40);
z=Add_Mouse_Page(M_Text_Coord,5,10,15,20);
Next, we define two mouse pages, Y & Z. Y is limited to the
rectangle from row 15, column 20 to row 24, column 40. Similarly, Z
is the area from (5,10) to (15,20).
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?