INF: Changing the Text Mode Mouse Cursor (94681)



The information in this article applies to:

  • Microsoft Basic Professional Development System for MS-DOS 7.1
  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5

This article was previously published under Q94681

SUMMARY

The text below demonstrates using CALL INTERRUPT to set the mouse text mode cursor to a specified ASCII character.

According to the "Microsoft Mouse Programmer's Reference," the software text cursor defined in mouse function 10 is one of the 256 characters of the ASCII character set. It does not specify how the character is selected.

MORE INFORMATION

The mouse driver creates the software text cursor by using a bitwise AND operation to combine the screen mask with the displayed character scan line. Then the XOR operation combines the result with the cursor mask to create the cursor.

The low-order bits (bits 0 through 7) in the cursor and screen mask specify the ASCII character for the mouse cursor.

The following program displays a smiley face character (ASCII code 1) as the cursor on a black background on the standard text screen.

Code Example

To run the following sample program in the QuickBasic environment, you must specify the /L option on the QuickBasic command line to load the default Quick library. Examples of the required command line follow:

QB /L (The MS-DOS command line if using QuickBasic)
QBX /L (The MS-DOS command line if using Basic PDS)

To create a .EXE file in MS-DOS, you must link the compiled program with the QB.LIB library (QBX.LIB for the Basic PDS).
' Use the following include file for QuickBasic for MS-DOS:
REM $INCLUDE: 'qb.bi'
' Use the following include file for Basic PDS for MS-DOS:
REM $INCLUDE: 'qbx.bi'

CLS                                     ' Clear the screen
DIM InRegs AS RegType
DIM OutRegs AS RegType                  ' Set up Interrupt Arrays

InRegs.ax = 0
CALL INTERRUPT(&H33, InRegs, OutRegs)   ' initialize mouse

InRegs.ax = 10                          ' choose mouse function 10
InRegs.bx = 0                           ' select software text cursor
InRegs.cx = &H1
                         ' The screen mask &H0004 produces a black
                         ' background when the bitwise AND operation
                         ' combines the mask with the displayed word.
                         ' The low-order bits (01) chooses the smiley
                         ' face as the ASCII character to display.

InRegs.dx = &H701
                         ' The cursor mask, &H0701, sets a white
                         ' foreground and a black background when the
                         ' bitwise XOR operation combines the mask
                         ' with the result above. The low-order bits
                         ' select the smiley face as the ASCII
                         ' character to display.

                         ' NOTE: The low-order bits for the CX and DX
                         ' registers must be the same.

CALL INTERRUPT(&H33, InRegs, OutRegs)   ' call the function

InRegs.ax = 1
CALL INTERRUPT(&H33, InRegs, OutRegs)   ' show mouse cursor
WHILE INKEY$ = "": WEND                 ' pause here while waiting
                                        ' for a key
END
				

REFERENCES

"Microsoft Programmers Reference Guide. 2nd Ed.", Microsoft Press, 1991

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB94681