SetConsoleCursorPosition

  BOOL SetConsoleCursorPosition(hConsoleOutput, coordCursor)    
  HANDLE hConsoleOutput; /* set cursor position in this screen buffer */
  COORD coordCursor; /* set cursor position to these coordinates */

The SetConsoleCursorPosition function sets the cursor position in the specified console screen buffer.

Parameters

hConsoleOutput

Specifies an open console output handle.

coordCursor

Specifies a COORD structure containing the new cursor position. The coordinates are the column and row of a screen buffer character cell. The coordinates must be within the boundaries of the screen buffer.

The COORD structure has the following format:

typedef struct _COORD { /* coord */

SHORT X; /* horizontal coordinate */

SHORT Y; /* vertical coordinate */

} COORD, *PCOORD;

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

The cursor position determines where characters written by WriteFile (or WriteConsole) or echoed by ReadFile (or ReadConsole) will be displayed. Use GetConsoleScreenBufferInfo to determine the current position of the cursor.

If the new cursor position is not within the boundaries of the screen buffer's window, the window origin will change to make the cursor visible.