1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
BOOL fillArea(const SMALL_RECT* lpScrollRectangle, WCHAR c)
{
HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(hConsoleOutput, &csbi))
{
CHAR_INFO fi = { c, csbi.wAttributes };
if (!lpScrollRectangle)
{
csbi.srWindow.Left = 0;
csbi.srWindow.Top = 0;
csbi.srWindow.Right = csbi.dwSize.X - 1;
csbi.srWindow.Bottom = csbi.dwSize.Y - 1;
lpScrollRectangle = &csbi.srWindow;
}
return ScrollConsoleScreenBufferW(hConsoleOutput, lpScrollRectangle, 0, csbi.dwSize, &fi);
}
return FALSE;
}
void print(SMALL_RECT rr,WCHAR wc)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 5);
fillArea(&rr,wc);
}
int main()
{
//The background is already colored
print({5,5,10,10},'*');
std::cin.get();
return 0;
}
|