From 662b140c62c9b20a47dfdb39f7f0e381de5da4e3 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Wed, 16 Nov 2011 00:52:11 -0800 Subject: [PATCH] Add a test program that uses the ioctl-like console interface to scroll and write. --- Misc/Win32Write1.cc | 40 ++++++++++++++++++++++++++++++++++++++++ Misc/build_win32.sh | 1 + 2 files changed, 41 insertions(+) create mode 100644 Misc/Win32Write1.cc diff --git a/Misc/Win32Write1.cc b/Misc/Win32Write1.cc new file mode 100644 index 0000000..5b99c36 --- /dev/null +++ b/Misc/Win32Write1.cc @@ -0,0 +1,40 @@ +/* + * A Win32 program that scrolls and writes to the console using the ioctl-like + * interface. + */ + +#include +#include + +int main() +{ + HANDLE conout = GetStdHandle(STD_OUTPUT_HANDLE); + + for (int i = 0; i < 80; ++i) { + + CONSOLE_SCREEN_BUFFER_INFO info; + GetConsoleScreenBufferInfo(conout, &info); + + SMALL_RECT src = { 0, 1, info.dwSize.X - 1, info.dwSize.Y - 1 }; + COORD destOrigin = { 0, 0 }; + CHAR_INFO fillCharInfo = { 0 }; + fillCharInfo.Char.AsciiChar = ' '; + fillCharInfo.Attributes = 7; + ScrollConsoleScreenBuffer(conout, &src, NULL, destOrigin, &fillCharInfo); + + CHAR_INFO buffer = { 0 }; + buffer.Char.AsciiChar = 'X'; + buffer.Attributes = 7; + COORD bufferSize = { 1, 1 }; + COORD bufferCoord = { 0, 0 }; + SMALL_RECT writeRegion = { 0, 0, 0, 0 }; + writeRegion.Left = writeRegion.Right = i; + writeRegion.Top = writeRegion.Bottom = 5; + WriteConsoleOutput(conout, + &buffer, bufferSize, bufferCoord, + &writeRegion); + + Sleep(250); + } + return 0; +} diff --git a/Misc/build_win32.sh b/Misc/build_win32.sh index 3943dfc..549cbbc 100644 --- a/Misc/build_win32.sh +++ b/Misc/build_win32.sh @@ -1,3 +1,4 @@ #!/bin/bash g++ Win32Echo1.cc -o Win32Echo1 g++ Win32Echo2.cc -o Win32Echo2 +g++ Win32Write1.cc -o Win32Write1