

If (!FillConsoleOutputAttribute(hConsole, // Handle to console screen bufferĬsbi.wAttributes, // Character attributes to useĭwConSize, // Number of cells to set attribute
#CLEARING THE SCREEN IN SPEEDCRUNCH SOFTWARE#
It comes with a few unique features (iso, a great text editor) and is built to last, created with the best software development tools available. Set the buffer's attributes accordingly. wxCommander application is a new two-panel file manager. &cCharsWritten)) // Receive number of characters written (TCHAR)' ', // Character to write to the bufferĬoordScreen, // Coordinates of first cell If (!FillConsoleOutputCharacter(hConsole, // Handle to console screen buffer

#include ĬOORD coordScreen = // home for the cursorĭwConSize = *
#CLEARING THE SCREEN IN SPEEDCRUNCH CODE#
The following sample code demonstrates this technique.

The third method is to write a function to programmatically clear the screen using the FillConsoleOutputCharacter and FillConsoleOutputAttribute functions. HStdout = GetStdHandle(STD_OUTPUT_HANDLE) SetConsoleCursorPosition(hConsole, csbi.dwCursorPosition) Move the cursor to the top left corner too. ScrollConsoleScreenBuffer(hConsole, &scrollRect, NULL, scrollTarget, &fill) Fill with empty spaces with the buffer's default text attribute. Scroll it upwards off the top of the buffer with a magnitude of the entire height. Scroll the rectangle of the entire buffer. If (!GetConsoleScreenBufferInfo(hConsole, &csbi)) Get the number of character cells in the current buffer. This matches the behavior of the command prompt cmd.exe. The second method is to write a function to scroll the contents of the screen or buffer and set a fill for the revealed space. You can find additional variations on this command in the virtual terminal sequences documentation on Erase In Display. Restore the mode on the way out to be nice to other command-line applications. 2J only clears the visible window and 3J only clears the scroll back. To also clear the scroll back, emit L"\x1b[3J" as well. If we fail, try to restore the mode on the way out. If (!WriteConsoleW(hStdOut, sequence, (DWORD)wcslen(sequence), &written, NULL)) Write the sequence for clearing the display. Mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING Hold original mode to restore on exit to be cooperative with other command-line apps. Fetch existing console mode so we correctly add a flag and not turn off others HStdOut = GetStdHandle(STD_OUTPUT_HANDLE) The first method is to set your application up for virtual terminal output sequences and then call the "clear screen" command. For more information, see the discussion of classic console APIs versus virtual terminal sequences. This is the recommended method using virtual terminal sequences for all new development.
