Cursor Types

A cursor VxD must draw the cursor appropriately for each video mode it supports. The VxD must draw a graphics cursor in graphics mode and a text cursor in text mode. A graphics cursor is a bitmapped image that moves over the images on the screen and can move to any pixel position on the display. A text cursor is typically either a block the size of a character cell, or a horizontal line that is one character-cell wide and one or more scan lines tall. A text cursor can occupy any character cell on the display. By default, VMOUSE displays a block cursor in text modes and an arrow cursor in graphics modes.

Graphics Cursors

To set a new graphics cursor, VMOUSE passes the address of a GRAPHICSCURSOR structure to the cursor VxD's SETGRAPHICSCURSOR function. The cursor VxD sets a new graphics cursor based on the information in the structure.

A graphics cursor is a bitmapped image that moves over the images on the screen. The width and height of the cursor image is expressed in pixels and is defined by the wWidth and wHeight members of the GRAPHICSCURSOR structure.

The pixels in the cursor image interact with the pixels on the display in a manner defined by the screen mask and the cursor mask. The screen mask determines whether the cursor pixels are part of the cursor's shape or part of the background; the cursor mask determines how the pixels under the cursor contribute to the color of the cursor.

To create the cursor, a cursor VxD operates on the bits in the computer's video memory that correspond to the image under the cursor. First, the VxD must expand each bit in the screen and cursor masks to match the number of bits in video memory required for each screen pixel's color information. Next, the VxD does a logical AND operation between the expanded screen-mask bits and the color-information bits. The color of the pixels under the cursor remains unchanged wherever a screen-mask bit is 1 and changes wherever the screen-mask bit is 0. Finally, the VxD does a logical XOR operation between the pixel bits and the expanded bits from the cursor mask. Where the cursor mask is 0, the screen pixels are unchanged. Where the mask is 1, the color of the pixels is inverted.

The dwOffset32Masks member of the GRAPHICSCURSOR structure specifies the offset from the beginning of the structure to the screen and cursor masks. The cursor mask must follow the screen mask.

A graphics cursor must have a hot spot, a single pixel in the cursor used to identify the cursor's location on the screen. The wHotX and wHotY members of GRAPHICSCURSOR define the coordinates of the hot spot relative to the upper-left corner of the cursor bitmasks.

See also GRAPHICSCURSOR, SETGRAPHICSCURSOR

Text Cursors

To set a new text cursor, VMOUSE calls the cursor VxD's SETTEXTCURSOR function, passing the address of a TEXTCURSOR structure. The cursor VxD sets a new text cursor based on the information in the structure.

The bFlags member of TEXTCURSOR indicates whether the new cursor is a hardware or software text cursor. If bFlags is 1, the new cursor is a hardware text cursor, and the XORMask and ANDMask members specify the first and last scan lines of the cursor. The VxD draws the cursor by directing the display adapter to turn on the specified scan lines in the character cell that contains the cursor. A scan line that is turned on typically appears as a bar in the character cell.

If the bFlags member of TEXTCURSOR is 0, the new cursor is a software text cursor. In this case, the XORMask and ANDMask members specify the cursor mask and screen mask, respectively. The cursor and screen masks are bitmasks that define how the cursor affects the character and attributes of the character cell it occupies. The screen mask is a 16-bit value that determines which of the character cell's attributes are preserved; the cursor mask is a 16-bit value that determines how the preserved attributes change to yield the cursor.

To draw the cursor, the VxD operates on the screen data that defines the attributes of the character cell occupied by the cursor. The screen data for a character cell has the following format.

Bits

Purpose

15

Sets blinking or nonblinking character

12 – 14

Sets background color

11

Sets intensity

8 – 10

Sets foreground color

0 – 7

Specifies ASCII value of character


The VxD first does a logical AND operation between the screen mask and the screen data for the character cell. Next, it does a logical XOR operation between the cursor mask and the result of the AND operation, producing the cursor's appearance on the display.

See also SETTEXTCURSOR, TEXTCURSOR