In line 23 (ClrConsole2) and line 39 (ClrConsole3) you can set the character which will be used to fill the console window. When I compile the code C code then it works as expected. The character will be used for the "clearing" of the console window.
Code: Select all
#Include "windows.bi"
Dim Shared As HANDLE hStdout
hStdout = GetStdHandle(STD_OUTPUT_HANDLE)
Sub ClrConsole(iSleep As Ushort = 100)
Shell("Cls")
Sleep(iSleep)
End Sub
Sub ClrConsole2(hConsole As HANDLE) 'https://docs.microsoft.com/en-us/windows/console/clearing-the-screen example 2
Dim As CONSOLE_SCREEN_BUFFER_INFO csbi
Dim As SMALL_RECT scrollRect
Dim As COORD scrollTarget
Dim As CHAR_INFO fill
GetConsoleScreenBufferInfo(hConsole, @csbi)
scrollRect.Left = 0
scrollRect.Top = 0
scrollRect.Right = csbi.dwSize.X
scrollRect.Bottom = csbi.dwSize.Y
scrollTarget.X = 0
scrollTarget.Y = (0 - csbi.dwSize.Y)
fill.Char.UnicodeChar = Cast(WCHAR, "_")
fill.Attributes = csbi.wAttributes
ScrollConsoleScreenBuffer(hConsole, @scrollRect, NULL, scrollTarget, @fill)
csbi.dwCursorPosition.X = 0
csbi.dwCursorPosition.Y = 0
SetConsoleCursorPosition(hConsole, csbi.dwCursorPosition)
End Sub
Sub ClrConsole3(hConsole As HANDLE) 'https://docs.microsoft.com/en-us/windows/console/clearing-the-screen example 3
Dim As CONSOLE_SCREEN_BUFFER_INFO csbi
Dim As COORD coordScreen = Type(0, 0)
Dim As DWORD cCharsWritten
Dim As CONSOLE_SCREEN_BUFFER_INFO csb
Dim As DWORD dwConSize
GetConsoleScreenBufferInfo(hConsole, @csbi)
dwConSize = csbi.dwSize.X * csbi.dwSize.Y
FillConsoleOutputCharacter(hConsole, Cast(CHAR, "."), dwConSize, coordScreen, @cCharsWritten)
GetConsoleScreenBufferInfo(hConsole, @csbi)
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, @cCharsWritten)
SetConsoleCursorPosition(hConsole, coordScreen)
End Sub
For i As Ubyte = 1 To 200
? "Line1",
Next
Sleep(500)
ClrConsole2(hStdout)
? "Clr"
Sleep