clrscr() and gotoxy() in Visual C++
-
It is well known that the common functions clrscr() and gotoxy() are not supported in Visual C++. But I presume that calling directly to DOS interruptions using in-line assembler would provide a convenient way of making this functions. Since I don't know Assembler programming, does anybody have these two function already made?
-
It is well known that the common functions clrscr() and gotoxy() are not supported in Visual C++. But I presume that calling directly to DOS interruptions using in-line assembler would provide a convenient way of making this functions. Since I don't know Assembler programming, does anybody have these two function already made?
I think you'll bugcheck on 98 with an _asm int 21; Here's some code that might help: The clrscr can be had with system("cls"); The more powerful way us to get a handle to the console and use the console api calls. The MS Knowledge base has a good article on clearing the screen - Q99261 - first, you need a handle though...
// with this handle, article Q99261
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);// call a console API just to test handle
CONSOLE_SCREEN_BUFFER_INFO csbi; // just to test// wow! hConsole is NULL! But this works! Go figure...
GetConsoleScreenBufferInfo(hConsole, &csbi);// now we can gotoxy with SetConsoleCursorPosition
COORD coord;
coord.X = 0;
coord.Y = 0;SetConsoleCursorPosition(hConsole, coord);
That should move the cursor to the top of the screen without clearing it. See Q99261 for the clear screen.