17.3.6 Moving and Hiding the Cursor

If you use WriteFile to write text to the screen buffer, characters are always written at the current cursor location. You can determine the current cursor position in the coordinate system of the screen buffer by calling GetConsoleScreenBufferInfo. Using the SetConsoleCursorPosition function, you can set the cursor position, and thereby control the placement of text by WriteFile. If you move the cursor, text at the new cursor location will be overwritten.

The cursor may be visible or hidden. When it is visible, its appearance may vary from completely filling the cell to a horizontal line at the bottom of the cell. You can query the appearance and visibility of the cursor using GetConsoleCursorInfo. This call returns the appearance of the cursor line as a percentage of a character cell that is filled by the cursor. The appearance and visibility of the cursor may be set using SetConsoleCursorInfo.

The state of the cursor (position, appearance, and visibility) is set independently for each screen buffer.