Microsoft KB Archive/26088

From BetaArchive Wiki
Knowledge Base


No Cursor Displayed in Graphics SCREENs 1, 2, 3, 7 through 13

Article ID: 26088

Article Last Modified on 8/16/2005



APPLIES TO

  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft GW-BASIC 3.2
  • Microsoft GW-BASIC 3.22
  • Microsoft GW-BASIC 3.23



This article was previously published under Q26088

SUMMARY

When you poll the INKEY$ function, a blinking cursor is displayed only in SCREEN 0 (text mode), and not in any graphics screen mode. A blinking cursor is not displayed in SCREEN 1, 2, 3, 7, 8, 9, 10, 11, 12, or 13 (please see the SCREEN statement in your Basic language reference manual to find out which SCREEN modes your version of Basic supports). This is a hardware video-graphics limitation, not a limitation of Basic.

In graphics modes, to get a cursor (which will be non-flashing and block-shaped), you can use the INPUT or LINE INPUT statement. You may also design a program that draws a cursor.

MORE INFORMATION

The following program does not display a blinking cursor in SCREEN modes other than 0:

   SCREEN 9 ' using SCREEN 0 lets you see cursor.
   LOCATE 1, 1, 1 ' Try to turn on the cursor
   PRINT "t": CLS
   10 a$ = INKEY$
   IF a$ = "" THEN GOTO 10
                

Using SCREEN 0, you get a blinking, underscore-shaped cursor while the INKEY$ function is being polled.

There is a more detailed explanation of this text-mode cursor in the "Video Basics" chapter of Peter Norton's "Programmer's Guide to the IBM PC," published by Microsoft Press (see Page 92 of the 1985 edition and Page 94 of the 1988 edition).

The blinking, underscore-shaped cursor is a feature of the text modes (i.e., SCREEN 0 only) and is created by hardware. To have a cursor in graphics mode, you must draw it within your program.

Below is an example of drawing a graphics mode cursor in SCREEN 9. It uses the underscore character, clears the screen, and starts over after you reach line 25, column 80.

SCREEN 9
CLS
PRINT "_"
y% = 1 ' Start at row 1
WHILE 1
a$ = INKEY$
IF a$ <> "" THEN
  x% = POS(0)
  LOCATE y%, x%
  PRINT a$;
  IF x% < 80 THEN
     PRINT "_";
     LOCATE y%, x% + 1
  ELSEIF y% = 25 THEN
      y% = 1
      x% = 0
      CLS
  ELSE
    y% = y% + 1
    x% = 0 ' Set the column to zero.
  END IF
END IF
WEND
                


Additional query words: QuickBas BasicCom

Keywords: KB26088