Кто-нибудь может обьяснить что делает кусок кода поподробнее, по строчкам? class Screen {
HANDLE m_hStdout;
CONSOLE_CURSOR_INFO m_cursorInfo;
COORD m_screenSize;
DWORD m_screenBufSize;
DWORD m_consoleMode;
public:
Screen() {
m_hStdout = GetStdHandle(STD_ERROR_HANDLE);
GetConsoleCursorInfo(m_hStdout, &m_cursorInfo);
m_cursorInfo.bVisible = FALSE;
SetConsoleCursorInfo(m_hStdout, &m_cursorInfo);
CONSOLE_SCREEN_BUFFER_INFO csbi;
(m_hStdout, &csbi);
m_screenSize.X = csbi.srWindow.Right - csbi.srWindow.Left + 1;
m_screenSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
m_screenBufSize = (DWORD)m_screenSize.X * m_screenSize.Y;
GetConsoleMode(m_hStdout, &m_consoleMode);
SetConsoleMode(m_hStdout, m_consoleMode | ENABLE_ECHO_INPUT);
}
~Screen() {
m_cursorInfo.bVisible = TRUE;
SetConsoleCursorInfo(m_hStdout, &m_cursorInfo);
SetConsoleMode(m_hStdout, m_consoleMode);
}
COORD getScreenSize() const { return m_screenSize; }
void out(const COORD &coord, char ch) {
SetConsoleCursorPosition(m_hStdout, coord);
DWORD chars_written;
WriteConsoleA(m_hStdout, &ch, DWORD(1), &chars_written, NULL);
}
void out_array(const char *buf, DWORD buflen) {
DWORD chars_written;
COORD coord{ 0,0 };
SetConsoleCursorPosition(m_hStdout, coord);
WriteConsoleA(m_hStdout, buf, buflen, &chars_written, NULL);
}
void cls() {
CONSOLE_SCREEN_BUFFER_INFO csbi;
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
(m_hStdout, &csbi);
DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
(m_hStdout, (TCHAR)' ', dwConSize, coordScreen, &cCharsWritten);
(m_hStdout, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(m_hStdout, coordScreen);
}
};

nadinnik4 nadinnik4    1   15.12.2020 15:19    0

Другие вопросы по теме Информатика