Answers for "up a line windows"

C++
0

up a line windows

#include <windows.h>

BOOL WINAPI ConsoleHandler(DWORD ctrl_type) {
 if ( ctrl_type == CTRL_C_EVENT || ctrl_type == CTRL_BREAK_EVENT ) {
ExitProcess(0);
}
return FALSE;
}

int main() {
HANDLE console_handle;
COORD dwSize;
COORD dwPosition;
DWORD written;
DWORD flag = 0;
CONSOLE_CURSOR_INFO cursor_info;
console_handle =
             CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, NULL,
             CONSOLE_TEXTMODE_BUFFER,
			NULL);

SetConsoleActiveScreenBuffer(console_handle);
SetConsoleCtrlHandler(ConsoleHandler, TRUE);
 dwSize.X = 80;
dwSize.Y = 24;
 SetConsoleScreenBufferSize(console_handle, dwSize);
cursor_info.dwSize = 1;
 cursor_info.bVisible = FALSE;
SetConsoleCursorInfo(console_handle, &cursor_info);
 SetConsoleTextAttribute(console_handle,FOREGROUND_RED | FOREGROUND_INTENSITY);
  dwPosition.X = 35;
dwPosition.Y = 12;
while ( TRUE ) {
SetConsoleCursorPosition(console_handle, dwPosition);
 if ( flag ^= 1 )
 WriteFile(console_handle, "Hello World",
 11, &written, NULL);
 else
 WriteFile(console_handle, "           ",
 11, &written, NULL);
Sleep(500);
  }
}
Posted by: Guest on September-23-2021

Browse Popular Code Answers by Language