home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************
- * MSCEXAMP.C *
- * *
- * Demonstrates use of the Microsoft Mouse from C 5.1 *
- * and QuickC. It checks to see that the mouse driver was *
- * installed, displays a graphics mode cursor, and limits *
- * mouse cursor motion to the middle of the screen. *
- * *
- * cmousem() is for medium memory model (QuickC default). *
- * For other memory models, replace cmousem() with the *
- * appropriate function: *
- * cmouses() - C small model *
- * cmousec() - C compact model *
- * cmousem() - C medium model *
- * cmousel() - C large or huge model *
- * *
- * Microsoft C 5.1: *
- * cl /AM mscexamp.c -link mouse *
- * *
- * QuickC: *
- * Program List MSCEXAMP.C, MOUSE.LIB *
- **********************************************************/
-
- #include <stdio.h>
- #include <dos.h>
- #include <graph.h>
-
- void chkdrv();
-
- main()
- {
- int m1, m2, m3, m4;
-
- chkdrv(); /* Check for mouse driver */
-
- m1 = 0; /* Initialize mouse */
- cmousem( &m1, &m2, &m3, &m4);
-
- if ( m1 == 0 )
- {
- printf("Microsoft Mouse NOT found");
- exit (-1); /* Exit, if mouse not found */
- }
-
- _setvideomode(_HRESBW);
-
- m1 = 4; /* Function call 4 */
- m3 = 200; /* Set mouse position at */
- m4 = 100; /* center of the screen */
- cmousem( &m1, &m2, &m3, &m4);
-
- m1 = 7; /* Function call 7 */
- m3 = 150; /* minimum horizontal value */
- m4 = 450; /* maximum horizontal value */
- cmousem( &m1, &m2, &m3, &m4);
-
- m1 = 8; /* Function call 8 */
- m3 = 50; /* minimum vertical value */
- m4 = 150; /* maximum vertical value */
- cmousem( &m1, &m2, &m3, &m4);
-
- printf("Graphics cursor limited to center of the screen.\n");
- printf("Press the left button to EXIT.");
-
- m1 = 1; /* Function 1, Show Cursor */
- cmousem( &m1, &m2, &m3, &m4);
-
- m2 = 0; /* Loop until left mouse */
- while ( m2 != 1 ) /* button is pressed */
- {
- m1 = 3;
- cmousem( &m1, &m2, &m3, &m4 );
- }
-
- m1 = 2; /* Function 2, hide cursor */
- cmousem( &m1, &m2, &m3, &m4);
-
- _setvideomode(_DEFAULTMODE);
- }
-
- void chkdrv ()
- {
- unsigned long address;
- unsigned char first_byte;
-
- union REGS inregs, outregs; /* Structures to contain */
- struct SREGS segregs; /* register values for intdosx */
-
- inregs.x.ax = 0x3533; /* Get interrupt vector for 0x33 */
- intdosx ( &inregs, &outregs, &segregs);
- address = (((long) segregs.es) << 16) + (long) outregs.x.bx ;
- first_byte = (unsigned char) * (long far *) address;
-
- /* Be sure vector isn't 0 and first instruction isn't iret */
- if ((address == 0L) || (first_byte == 0xCF))
- {
- printf ("\nThe Mouse Driver must be installed to use this program");
- exit ();
- }
- }
-