1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
bool move_rect(
int x, int y,
int new_x, int new_y,
int width, int height
) {
HANDLE hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
PCHAR_INFO buffer = new CHAR_INFO[ width * height ];
COORD buffer_size = { width, height };
COORD buffer_index = { 0, 0 }; // read/write rectangle has upper-right corner at upper-right corner of buffer
SMALL_RECT read_rect = { x, y, x + width - 1, y + height - 1 };
SMALL_RECT write_rect = { new_x, new_y, new_x + width - 1, new_y + height - 1 };
bool result = ReadConsoleOutput( hStdOut, buffer, buffer_size, buffer_index, &read_rect )
&& WriteConsoleOutput( hStdOut, buffer, buffer_size, buffer_index, &write_rect );
delete [] buffer;
return result;
}
|