Microsoft KB Archive/32346

Programming Custom Mouse Cursors in Microsoft C PSS ID Number: Q32346 Article last modified on 05-14-1993 PSS database name: H_Mouse

1.01

MS-DOS

Summary:

Several special considerations must be met when programming custom cursors in Microsoft C for the Microsoft Mouse. The “Microsoft Mouse Programmer’s Reference Guide” provides a number of custom-cursor examples written in BASIC. The following are two methods of implementing custom mouse cursors in Microsoft C.

More Information:

Example 1
void cursor { unsigned short cursor[32]; int m1, m2, m3, m4; union REGS inregs, outregs; struct SREGS segregs;

/* STANDARD CURSOR SHAPE (Pages 7-24) revised for Microsoft C using a linear array to store the cursor.

Define the Screen Mask */

cursor[ 0] = 0x3FFF; cursor[ 1] = 0x1FFF; cursor[ 2] = 0x0FFF; cursor[ 3] = 0x07FF; cursor[ 4] = 0x03FF; cursor[ 5] = 0x01FF; cursor[ 6] = 0x00FF; cursor[ 7] = 0x007F; cursor[ 8] = 0x003F; cursor[ 9] = 0x001F; cursor[10] = 0x01FF; cursor[11] = 0x10FF; cursor[12] = 0x30FF; cursor[13] = 0xF87F; cursor[14] = 0xF87F; cursor[15] = 0xFC3F; /* Define the cursor Mask */

cursor[16] = 0x0000; cursor[17] = 0x4000; cursor[18] = 0x6000; cursor[19] = 0x7000; cursor[20] = 0X7800; cursor[21] = 0x7C00; cursor[22] = 0x7E00; cursor[23] = 0x7F00; cursor[24] = 0x7F80; cursor[25] = 0x78C0; cursor[26] = 0x7C00; cursor[27] = 0x4600; cursor[28] = 0x0600; cursor[29] = 0x0300; cursor[30] = 0x0300; cursor[31] = 0x0180; /* Set the mouse cursor shape and hot spot through Mouse Function 9. */

inregs.x.ax = 9; inregs.x.bx = -1;   /* Horizontal hot spot */ inregs.x.cx = -1;   /* Vertical hot spot   */ inregs.x.dx = (unsigned int)&cursor[0]; segread(&segregs); segregs.es = segregs.ds; int86x(51, &inregs, &outregs, &segregs); segread(&segregs); }

Example 2
void cursor2 { unsigned short cursor2[2][16]; int m1, m2, m3, m4; union REGS inregs, outregs; struct SREGS segregs;

/* STANDARD CURSOR SHAPE (Pages 7-24) revised for Microsoft C two-dimensional array definition.

Define the Screen Mask */

cursor2[0][0] = 0x3FFF; cursor2[0][1] = 0x1FFF; cursor2[0][2] = 0x0FFF; cursor2[0][3] = 0x07FF; cursor2[0][4] = 0x03FF; cursor2[0][5] = 0x01FF; cursor2[0][6] = 0x00FF; cursor2[0][7] = 0x007F; cursor2[0][8] = 0x003F; cursor2[0][9] = 0x001F; cursor2[0][10] = 0x01FF; cursor2[0][11] = 0x10FF; cursor2[0][12] = 0x30FF; cursor2[0][13] = 0xF87F; cursor2[0][14] = 0xF87F; cursor2[0][15] = 0xFC3F; /* Define the cursor2 Mask */

cursor2[1][0] = 0x0000; cursor2[1][1] = 0x4000; cursor2[1][2] = 0x6000; cursor2[1][3] = 0x7000; cursor2[1][4] = 0X7800; cursor2[1][5] = 0x7C00; cursor2[1][6] = 0x7E00; cursor2[1][7] = 0x7F00; cursor2[1][8] = 0x7F80; cursor2[1][9] = 0x78C0; cursor2[1][10] = 0x7C00; cursor2[1][11] = 0x4600; cursor2[1][12] = 0x0600; cursor2[1][13] = 0x0300; cursor2[1][14] = 0x0300; cursor2[1][15] = 0x0180; /* Set the mouse cursor2 shape and hot spot through Mouse Function 9. */

inregs.x.ax = 9; inregs.x.bx = -1;   /* Horizontal hot spot */ inregs.x.cx = -1;   /* Vertical hot spot   */ inregs.x.dx = (unsigned int) &cursor2[0][0]; segread(&segregs); segregs.es = segregs.ds; int86x(51, &inregs, &outregs, &segregs); segread(&segregs); }

Additional reference words: 8.x 9.00 1.01

Copyright Microsoft Corporation 1993.