⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moustrap.prn

📁 又一个关于鼠标驱动的C程序
💻 PRN
📖 第 1 页 / 共 5 页
字号:



















                                        - Page 8 -






                                                      MouseTrap Library, Rel 1.01
                                                                February 12, 1989

                       Set_Mouse_Position

               Syntax:
                    #include <moustrap.h>

                    void Set_Mouse_Position(mouse_t X, mouse_t Y);


               Description:
                    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).

               Return Value:
                    None.

               See Also:
                    Get_Mouse_Position

               Example:
                    #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 9 -






                                                      MouseTrap Library, Rel 1.01
                                                                February 12, 1989

                                      Get_Mouse_Press
                                     Get_Mouse_Release

               Syntax:
                    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);


               Description:
                    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.

               Return Value:
                    The number of time Button was pressed (released) since the   
                    last call to Get_Mouse_Press (Get_Mouse_Release).

               See Also:
                    Get_Mouse_Position 

               Example:
                    #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)) 
                              printf("Left buttom was pressed at %d,%d\n", x,y);
                              }
                    }





                                        - Page 10 -






                                                      MouseTrap Library, Rel 1.01
                                                                February 12, 1989

                      Set_Mouse_Limit                         (v1.0)
                      Set_Mouse_Limit_Horiz                   (v1.1)
                      Set_Mouse_Limit_Vert                    (v1.1)
                      Set_Mouse_Region                        (v1.1)

               Syntax:
                    void    Set_Mouse_Limits(Direction, Min, Max);
                    mouse_t Direction;       /* M_HORIZ -or- M_VERT */
                    mouse_t Min;
                    mouse_t Max;

                    void    Set_Mouse_Limits_Horiz(Left, Right);
                    void    Set_Mouse_Limits_Vert(Top, Bottom);
                    void    Set_Mouse_Region(Top, Left, Bottom, Right);          

                    mouse_t Top;
                    mouse_t Left;
                    mouse_t Bottom;
                    mouse_t Right;

               Description:
                    These functions give a variety of ways to forces the mouse   
                    cursor's  movements to remain within specified limits. The
                    various edges are given using graphic coordinates (0-629)
                    (0-199).
                    
                         "That seems like a fairly simple concept", you should
                    now be saying, "So, why does it take -FOUR- separate
                    functions ?" Funny you should ask. In release 1.0, only
                    Set_Mouse_Limit existed. It was functional, but inelegant, 
                    since it required two calls to properly limit the cursor. It 
                    was written that way mainly because the function it was
                    adapted from was written that way. Realizing that this was a
                    particularly poor reason to do something badly,
                    Set_Mouse_Region was added.  It accomplishs the task with
                    just one call, and  maintains  the  format of the other
                    function  in the library.  However, it's not as flexible as 
                    the original, so Set_Mouse_Limits_Horiz, and
                    Set_Mouse_Limits_Vert were added. Set_Mouse_Limits hung
                    around to maintain upward compatiblity with release 1.0      

               Return Value:
                    None










                                        - Page 11 -





                                                      MouseTrap Library, Rel 1.01
                                                                February 12, 1989


               Example:

                    #include <moustrap.h>
                    #include <stdio.h>
                    
                    main()
                    {
                         Check_Mouse();

                         Set_Mouse_Region(50,160,150,480);
                          /* Mouse is now limited to the center of the screen */ 

                         Read_Mouse();

                    }





































                                        - Page 12 -





                                                      MouseTrap Library, Rel 1.01
                                                                February 12, 1989

                                   Set_Mouse_Text_Cursor

               Syntax:
                    void    Set_Mouse_Text_Cursor(Type, P1, P2);

                    mouse_t Type; /* 1 = Hardware Cursor | 0 = Software Cursor */
                    mouse_t P1    /* Start scan line     |     Screen Mask     */
                    mouse_t P2;   /* Stop  scan line     |     Cursor Mask     */

               Description:
                         Set_Mouse_Text_Cursor describes how the mouse cursor
                    will appear on the screen while in text modes.  This can be
                    done in either of two way:  by using the Hardware cursor, or
                    the Software cursor.  The Hardware cursor is the same one
                    that the keyboard uses, that is, it looks just like the
                    keyboard cursor, and can be moved  using the BIOS "move
                    cursor"  functions.  If the hardware cursor is used,  P1  & 
                    P2 give the scan lines for that cursor.  For normal screen
                    uses that is 6 & 7.

                         The Software cursor is a little more complex.  There, P1
                    is  the "Screen mask" and P2 is the "Cursor Mask", and they
                    are given in the form of a color attribute and character. 
                    When the software cursor is drawn on the screen,  the
                    character and color attribute originally at that location is
                    first ANDed with the screen mask, then the result of that is
                    XORed with the cursor mask. If the screen mask is 0, the net
                    effect is that the current value at that location is
                    replaced by the cursor mask.  If the screen mask is      
                    nonzero, the current value at the screen location WILL
                    affect of character or color of the mouse cursor.

                         For example, if the screen mask was 0x0800, the color
                    intensity bit (controlling brightness of the foreground)
                    would be preserved.  Hence, the mouse cursor would become
                    bright of it passed throught an area of bright text.  Or, if
                    the screen mask was 0xF000, and the background color of the
                    cursor mask was 0 (ie in the form  0x0---), the current
                    background color will always be maintained underneath      
                    the  mouse  cursor.  The effects become very strange if you
                    use nonzero values in the character portion of the screen
                    mask (the last two digits), which causes the screen character
                    to affect the look of the mouse cursor.  This is best left to
                    private experimentation.

               Return Value:
                    None.

               See Also:
                    TC() macro Set_Mouse_Graphic_Cursor



                                        - Page 13 -





                                                      MouseTrap Library, Rel 1.01
                                                                February 12, 1989

                                 Set_Mouse_Graphic_Cursor

               Syntax:
                    void Set_Mouse_Graphic_Cursor(mouse_t Hot_X, mouse_t Hot_Y,  
                                                  mouse_t Cursor[2][16]);

               Description:
                         Set_Mouse_Graphic_Cursor changes how the mouse cursor
                    will appear on the screen,  while in graphic modes.  The
                    graphic cursor can  be  used in any of the graphic modes.  
                    The graphic cursor is defined  by two 16 bit by 16 bit
                    arrays, the screen mask, and  the cursor mask.  This defines 
                    a 16 by 16 pixel square in high-resolution or EGA mode, an 8
                    by 16 pixel block in medium resolution 4-color mode, and a 4
                    by 16 pixel block in low resolution 16 color mode.

                         When a graphic cursor is displayed on  the  screen,
                    three operations take place.  First, the screen image "under"
                    the cursor is saved, Then, the screen mask is logically ANDed
                    with the  screen image.  Finally, the cursor mask is logic-
                    ally XORed with the result of the first operation.

                    The logically result of these operations is:
                       Screen mask     Cursor Mask      Result
                             0              0             0
                             0              1             1
                             1              0           Same as original bit     
                             1              1           Inverse of original bit. 

                         Remember, in CGA color modes,  more than one bit is
                    required  for each pixel.

               Return Value:
                    None

               See Also:
                    Set_Mouse_Text_Cursor  Peace[][]  CrossHair[][]  Lightening[][]
















                                        - Page 14 -





                                                      MouseTrap Library, Rel 1.01
                                                                February 12, 1989

               Example:
                    #include <moustrap.h>
                    #include <stdio.h>

                    mouse_t Lightening[2][16] = {
                         {
                         0xFFF7,         /* 11111111 11110111b    */
                         0xFFCF,         /* 11111111 11001111b    */
                         0xFF9F,         /* 11111111 10011111b    */
                         0xFF3F,         /* 11111111 00111111b    */
                         0xFE7F,         /* 11111110 01111111b    */
                         0xFCFF,         /* 11111100 11111111b    */
                         0xF9FF,         /* 11111001 11111111b    */
                         0xF803,         /* 11111000 00000111b    */
                         0xFFE3,         /* 11111111 11100111b    */
                         0xFFCF,         /* 11111111 11001111b    */
                         0xFF9F,         /* 11111111 10011111b    */
                         0xFF3F,         /* 11111111 00111111b    */
                         0xFE7F,         /* 11111110 01111111b    */
                         0xFCFF,         /* 11111100 11111111b    */
                         0xF9FF,         /* 11111001 11111111b    */
                         0xF7FF},        /* 11110111 11111111b    */

                         {0x0008,         /* 00000000 00001000b    */
                          0x0030,         /* 00000000 00110000b    */
                          0x0060,         /* 00000000 01100000b    */
                          0x00C0,         /* 00000000 11000000b    */
                          0x0180,         /* 00000001 10000000b    */
                          0x0300,         /* 00000011 00000000b    */
                          0x0600,         /* 00000110 00000000b    */
                          0x03F8,         /* 00000111 11111000b    */
                          0x0018,         /* 00000000 00011000b    */
                          0x0030,         /* 00000000 00110000b    */
                          0x0060,         /* 00000000 01100000b    */
                          0x00C0,         /* 00000000 11000000b    */
                          0x0180,         /* 00000001 10000000b    */
                          0x0300,         /* 00000011 00000000b    */
                          0x0600,         /* 00000110 00000000b    */
                          0x0800}         /* 00001000 00000000b    */
                          };  

                    main()
                    {
                         mouse_t s,x,y;
                         
                         if (Check_Mouse()) {
                              Set_Mouse_Graphic_Cursor(4,15,Lightening);
                              Show_Mouse();
                              }
                    }



                                        - Page 15 -



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -