-
Notifications
You must be signed in to change notification settings - Fork 0
/
setconsolewindow.cpp
48 lines (36 loc) · 1008 Bytes
/
setconsolewindow.cpp
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
38
39
40
41
42
43
44
45
46
47
48
/*
Example of setting of console window of given size
*/
#include <windows.h>
#include <iostream>
void SetConsoleWindow(SHORT cols, SHORT rows)
{
HANDLE conout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFOEX sbInfoEx;
sbInfoEx.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
GetConsoleScreenBufferInfoEx(conout, &sbInfoEx);
sbInfoEx.dwSize = { cols, rows };
sbInfoEx.srWindow = { 0, 0, cols, rows };
sbInfoEx.dwMaximumWindowSize = { cols, rows };
SetConsoleScreenBufferInfoEx(conout, &sbInfoEx);
DWORD mode;
GetConsoleMode(conout, &mode);
mode &= ~ENABLE_WRAP_AT_EOL_OUTPUT;
SetConsoleMode(conout, mode);
SetConsoleTitle(TEXT("Console Window Test"));
}
int main()
{
SHORT cols = 100, rows = 60;
SetConsoleWindow(cols, rows);
for (int y = 1; y <= rows; ++y)
{
for (int x = 0; x < cols; ++x)
std::cout << x % 10;
if (y < rows)
std::cout << std::endl;
}
//SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), { 0, 0 });
std::cin.get();
return 0;
}