ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Mhandler.c and Mhandler.obj ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ By Jason Walton ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The source file and this documentation are absoluteley FREE. They are to be distributed freely in their unmodified form without payment. My purpose for writing this program was to allow my programs to incorporate the mouse as a more 'friendly' as well as easy interface. I have merely written this documentation and ARCed the source for public use. I hope you will all enjoy. Mhandler.c was written using the information on the Microsoft Mouse driver in PC Magazine vol.6 number 13, in the "Productivity" section. Please refer here for more details on the mouse driver (by the way, this program is compatible with most any mouse driver, Microsoft or no). In my reference to the 'mouse driver' I mean the file that was probably supplied with your mouse, commonly a file called 'mouse.com'. Mhandler.c is preferably to be compiled to an .OBJ file using Turbo C and the same memory model as the program that you plan to use it in. To Use Mhandler, you must either link your program to the Mhandler.OBJ file (using a .PRJ file), or if you use the command line version, (of Turbo C) you can include Mhandler.c in your program. It is not possible to include the Mhandler.c program when operating in the integrated environment because it does not support in-line assembly. My purpose for writing this program in C using in-line assembly is the fact that I am not familiar with any assemblers, and this seemed the easiest (as well as most convenient) method. In the following, I will explain the use of the functions included in the Mhandler.c program. int minit(): Resets the mouse driver and returns -1 if no mouse is present, 0 if one is. void mshow() and void mhide(): Simply displays and hides the mouse cursor. int mx() and int my(): Returns the x and y position of the mouse cursor. (not to be confused with the regular text cursor) char mb(): Returns 1 for first button, 2 for second button, and 4 for the center button (If one exists for your mouse). You must add these values together to get "chord" values (values you get from pressing two buttons at a time). An example of this would be if you pressed the right and left buttons at the same time, this would return 3, 1+2=3. or if you pressed the center button and right button, you would get 6, 4+2=6. The "char" type is used to save space because a char takes only one bye, but has a range of 0 to 255(it is best to have your TC compiler set to handle all char definitions as unsigned, the only sensible setting since there are no negative ASCII characters), where a int takes two bytes and has a much larger capacity. All further "char" declarations should be treated this way. void mdef(char def,int attr1,int attr2): This defines the mouse cursor. When def is set to 1 the 'software', or regular blinking cursor is used, and the attr? variables have no meaning. When def is set to zero, you must define the cursor with the attr? variables, which are passed as hex. Setting these variables is a thing I do not quite understand fully, yet. I suggest playing with these variables, to discover further understanding than the small ammount that I know and can tell you. Here are some examples (attr1 is the first hex number, attr2 will be the second):0x77ff 0x7700 creates a solid, nonblinking, square which inverstes whatever is underneath it. Here is my understanding of the seperate parts of these numbers: 0x77ff 0x7700     1 2 3 4 1: These two numbers represent the forground color of the cursor, for example 77 is white, 11 is blue, 66 is brown. To get the txt underneath the cursor to be this color, subtract this number from the background color. If you are familiar with the color table, this should show a pattern. If you are not, here is the color table: DEC HEX COLOR ÄÄÄ ÄÄÄ ÄÄÄÄÄ 0 0 black 1 1 blue 2 2 green 3 3 cyan 4 4 red 5 5 purple 6 6 brown 7 7 white 8 8 gray 9 9 bright blue 10 a bright green 11 b bright cyan 12 c bright red 13 d bright purple 14 e yellow 15 f bright white 2: This bye determines whether the character under the cursor is displayed or not, if it is 00, then it is not, if it is ff, it is. This byte should be zero if you wish to use byte 4. 3: Background color, see 1 and 4. 4: Character to be displayed. The color is set by byte 3, which is set similar to byte 1. The ASCII code is merely entered. There is a small thing that happens when you try to use BOTH the background and foreground colors and when the forground color is more than the background color, the ouput may not be quite how you intended. Please note that I do not have all of the answers, and that you must do some experimenting on your own, I have included the file mtest.com to help you experiment. Here is an example of a useful combination: 0x[background]00 0x[color][ascii]. There is a funny thing that happens when you try to use BOTH the background and foreground colors, the ouput may not be quit how you intended. Limitx(int min,int max) and Limity(int min,int max), these functions limit the mouse cursor's area of the screen that it can 'roam'. mpos(int x,int y), this function places the mouse crsor at the specified x and y coordinates. This concludes the definitions of my mouse handler functions. If you wish to use the standard arrow as a mouse cursor in graphics mode, simply go into graphics mode and define the the cursor as a hardware cursor, and you've got an arrow. I think that I have covered my mouse handler thoroughly enough, and if you have any questions/ comments/ complaints(*gasp*), just leave me E-Mail at my GEnie address of J.WALTON11. I hope that you enjoy, Jason. (J.WALTON11)