"survivor" <su******@discussions.microsoft.com> wrote:
When developing a console application how do I place the cursor at a
specific colomn and row?
If you're using the beta of the new .NET Framework 2.0, then you can use the
Console.SetCursorPosition() method to do this, or alternatively, assign the
properties Console.CursorLeft and Console.CursorTop. There's no
functionality in the .NET Framework 1.0 for this, but you can invoke the
Win32 API call SetConsoleCursorPosition() instead. This function should do
the trick:
void SetCursorPosition(int row, int col) {
COORD coord;
coord.X = col;
coord.Y = row;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_H ANDLE), coord);
}
Make sure you "#include <windows.h>"; this should usually be put in
stdafx.h. In other languages like Visual Basic and C# you would need to use
DllImport to import the appropriate native calls. I hope this helps.
--
Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included code samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm